Module Response.Error_code

Standard JSON-RPC 2.0 error codes.

These codes follow the JSON-RPC 2.0 specification for structured error responses. Using the typed codes instead of raw integers improves code clarity and prevents typos. Polymorphic variants allow for easy extension.

type t = [
  1. | `Parse_error
    (*

    -32700: Invalid JSON received

    *)
  2. | `Invalid_request
    (*

    -32600: The request object is invalid

    *)
  3. | `Method_not_found
    (*

    -32601: The requested method does not exist

    *)
  4. | `Invalid_params
    (*

    -32602: Invalid method parameters

    *)
  5. | `Internal_error
    (*

    -32603: Internal server error

    *)
  6. | `Custom of int
    (*

    Application-specific error codes

    *)
]
val to_int : [< t ] -> int

to_int t converts an error code to its integer representation.

val of_int : int -> t

of_int n converts an integer to an error code. Standard codes are mapped to their variants, others become `Custom n.