IMAP in OCaml
at main 50 lines 1.6 kB view raw
1(*--------------------------------------------------------------------------- 2 Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 SPDX-License-Identifier: ISC 4 ---------------------------------------------------------------------------*) 5 6(** IMAP Client Errors 7 8 Error types for IMAP client operations, integrated with Eio's exception 9 handling. *) 10 11(** {1 Error Types} *) 12 13type t = 14 | Connection_error of { reason : string } 15 | Protocol_error of { code : Code.t option; text : string } 16 | Parse_error of { reason : string; data : string option } 17 | State_error of { expected : string; actual : string } 18 | Timeout of { operation : string } 19 | Capability_missing of { capability : string } 20 | Authentication_error of { mechanism : string; reason : string } 21 22(** {1 Pretty Printing} *) 23 24val pp : Format.formatter -> t -> unit 25val to_string : t -> string 26 27(** {1 Eio Integration} *) 28 29type Eio.Exn.err += E of t 30(** Exception type for IMAP errors. *) 31 32val err : t -> exn 33(** [err e] wraps error [e] in an Eio exception. *) 34 35val raise : t -> 'a 36(** [raise e] raises error [e] as an Eio exception. *) 37 38val of_eio_exn : exn -> t option 39(** [of_eio_exn exn] extracts an IMAP error from an Eio exception. *) 40 41(** {1 Error Classification} *) 42 43val is_retryable : t -> bool 44(** [is_retryable e] returns [true] if the error may succeed on retry. *) 45 46val is_auth_error : t -> bool 47(** [is_auth_error e] returns [true] if this is an authentication error. *) 48 49val is_state_error : t -> bool 50(** [is_state_error e] returns [true] if this is a state error. *)