Something went wrong. Try again.
Provider-neutral LLM requests, transcripts and responses, I/O-free
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142(*--------------------------------------------------------------------------- Copyright (c) 2026 Invariant Systems. All rights reserved. SPDX-License-Identifier: ISC ---------------------------------------------------------------------------*)
(* The contracts of [Llm.Error]. *)
open Llmopen Fixture
let suite = group "Error" [ test "accessors and jsont" (fun () -> let error = Error.v ~kind:Error.Transport ~phase:Error.Stream ~provider:openai ~status:503 ~request_id:"req_1" ~redacted_body:"unavailable" "provider unavailable" in equal string ~msg:"label" "transport" (Error.label (Error.kind error)); equal phase_t ~msg:"phase" Error.Stream (Error.phase error); equal (option int) ~msg:"status" (Some 503) (Error.status error); equal (option string) ~msg:"request id" (Some "req_1") (Error.request_id error); roundtrip "error" error_t Error.jsont error); test "rejects invalid construction" (fun () -> expect_invalid_arg "empty message" (fun () -> Error.v ~kind:Error.Provider ""); expect_invalid_arg "low status" (fun () -> Error.v ~kind:Error.Provider ~status:99 "bad"); expect_invalid_arg "high status" (fun () -> Error.v ~kind:Error.Provider ~status:600 "bad"); expect_invalid_arg "reserved other" (fun () -> Error.v ~kind:(Error.Other "auth") "bad"); expect_invalid_arg "invalid other" (fun () -> Error.v ~kind:(Error.Other "Bad") "bad"); expect_invalid_arg "invalid other label" (fun () -> Error.label (Error.Other "Bad"))); prop "jsont round-trips (property)" error_gen (fun e -> roundtrip "error" error_t Error.jsont e); ]