Matrix protocol in OCaml, Eio specialised
1(** Matrix error types and handling. *)
2
3(** Matrix API error codes per spec. *)
4type errcode =
5 | M_FORBIDDEN
6 | M_UNKNOWN_TOKEN
7 | M_MISSING_TOKEN
8 | M_BAD_JSON
9 | M_NOT_JSON
10 | M_NOT_FOUND
11 | M_LIMIT_EXCEEDED
12 | M_UNRECOGNIZED
13 | M_UNKNOWN
14 | M_UNAUTHORIZED
15 | M_USER_DEACTIVATED
16 | M_USER_IN_USE
17 | M_INVALID_USERNAME
18 | M_ROOM_IN_USE
19 | M_INVALID_ROOM_STATE
20 | M_THREEPID_IN_USE
21 | M_THREEPID_NOT_FOUND
22 | M_THREEPID_AUTH_FAILED
23 | M_THREEPID_DENIED
24 | M_SERVER_NOT_TRUSTED
25 | M_UNSUPPORTED_ROOM_VERSION
26 | M_INCOMPATIBLE_ROOM_VERSION
27 | M_BAD_STATE
28 | M_GUEST_ACCESS_FORBIDDEN
29 | M_CAPTCHA_NEEDED
30 | M_CAPTCHA_INVALID
31 | M_MISSING_PARAM
32 | M_INVALID_PARAM
33 | M_TOO_LARGE
34 | M_EXCLUSIVE
35 | M_RESOURCE_LIMIT_EXCEEDED
36 | M_CANNOT_LEAVE_SERVER_NOTICE_ROOM
37 | M_WEAK_PASSWORD
38 | M_UNKNOWN_CODE of string
39
40(** Convert errcode to string. *)
41val errcode_to_string : errcode -> string
42
43(** Convert string to errcode. *)
44val errcode_of_string : string -> errcode
45
46(** Matrix API error response. *)
47type matrix_error = {
48 errcode : errcode;
49 error : string;
50 retry_after_ms : int option;
51 soft_logout : bool option;
52}
53
54(** jsont codec for matrix_error. *)
55val matrix_error_jsont : matrix_error Jsont.t
56
57(** SDK error type. *)
58type t =
59 | Matrix_error of matrix_error
60 | Network_error of string
61 | Json_error of string
62 | Http_error of { status : int; body : string }
63
64(** Result type alias. *)
65type 'a result = ('a, t) Stdlib.result
66
67(** Pretty print error. *)
68val pp : Format.formatter -> t -> unit
69
70(** Convert error to string. *)
71val to_string : t -> string