OCaml Claude SDK using Eio and Jsont
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 62 lines 1.8 kB view raw
1(*--------------------------------------------------------------------------- 2 Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 SPDX-License-Identifier: ISC 4 ---------------------------------------------------------------------------*) 5 6(** Error handling for the claude library. *) 7 8type t = 9 | Cli_not_found of string 10 | Process_error of string 11 | Connection_error of string 12 | Protocol_error of string 13 | Timeout of string 14 | Permission_denied of { tool_name : string; message : string } 15 | Hook_error of { callback_id : string; message : string } 16 | Control_error of { request_id : string; message : string } 17 18exception E of t 19 20val pp : Format.formatter -> t -> unit 21(** Pretty-print an error. *) 22 23val to_string : t -> string 24(** Convert error to string. *) 25 26val raise : t -> 'a 27(** [raise err] raises [E err]. *) 28 29(** {1 Convenience Raisers} *) 30 31val cli_not_found : string -> 'a 32 33val process_error : string -> 'a 34(** Raise a process error. *) 35 36val connection_error : string -> 'a 37(** Raise a connection error. *) 38 39val protocol_error : string -> 'a 40(** Raise a protocol error. *) 41 42val timeout : string -> 'a 43(** Raise a timeout error. *) 44 45val permission_denied : tool_name:string -> message:string -> 'a 46(** Raise a permission denied error. *) 47 48val hook_error : callback_id:string -> message:string -> 'a 49(** Raise a hook error. *) 50 51val control_error : request_id:string -> message:string -> 'a 52(** Raise a control error. *) 53 54(** {1 Result Helpers} *) 55 56val ok : msg:string -> ('a, string) result -> 'a 57(** [ok ~msg result] returns the Ok value or raises Protocol_error with msg 58 prefix. *) 59 60val ok' : msg:string -> ('a, string) result -> 'a 61(** [ok' ~msg result] returns the Ok value or raises Protocol_error with string 62 error. *)