(** JMAP Error Types and Exception Handling *) (** Error classification level *) type error_level = | Request_level (** HTTP 4xx/5xx errors before request processing *) | Method_level (** Method execution errors *) | Set_level (** Object-level errors in /set operations *) (** Request-level errors (RFC 8620 Section 3.6.1) *) type request_error = | Unknown_capability of string | Not_json | Not_request | Limit of string (** Method-level errors (RFC 8620 Section 3.6.2) *) type method_error = | Server_unavailable | Server_fail of string option | Server_partial_fail | Unknown_method | Invalid_arguments of string option | Invalid_result_reference | Forbidden | Account_not_found | Account_not_supported_by_method | Account_read_only | Request_too_large | State_mismatch | Cannot_calculate_changes | Anchor_not_found | Unsupported_sort | Unsupported_filter | Too_many_changes | From_account_not_found | From_account_not_supported_by_method (** Set-level errors (RFC 8620 Section 5.3) *) type set_error_type = | Forbidden | Over_quota | Too_large | Rate_limit | Not_found | Invalid_patch | Will_destroy | Invalid_properties | Singleton | Already_exists | Mailbox_has_child | Mailbox_has_email | Blob_not_found | Too_many_keywords | Too_many_mailboxes | Invalid_email | Too_many_recipients | No_recipients | Invalid_recipients | Forbidden_mail_from | Forbidden_from | Forbidden_to_send | Cannot_unsend (** SetError detail with optional fields *) type set_error_detail = { error_type : set_error_type; description : string option; properties : string list option; existing_id : string option; not_found : string list option; max_recipients : int option; invalid_recipients : string list option; } (** Main JMAP exception type *) exception Jmap_error of error_level * string * string option (** Parse error for JSON parsing failures *) exception Parse_error of string (** Helper constructors for exceptions *) val request_error : request_error -> exn val method_error : method_error -> exn val set_error : set_error_detail -> exn val parse_error : string -> exn (** Convert error types to strings for serialization *) val request_error_to_string : request_error -> string val method_error_to_string : method_error -> string val set_error_type_to_string : set_error_type -> string val set_error_type_of_string : string -> set_error_type (** Parse set_error_detail from JSON *) val parse_set_error_detail : Ezjsonm.value -> set_error_detail