Module Rest.Error

Represents all error conditions possible by the REST services. In general the REST services don't throw exceptions- instead they report an error variant with some provisional failure information.

type http = [
  1. | `Bad_request of string
  2. | `Not_found
  3. | `Service_unavailable of string
  4. | `Not_acceptable of string
  5. | `Unauthorized of string
]

An error at the http protocol level. Each variant is named according to it's corresponding http status code. The body of the http response is append to the variant payload if it exists.

val sexp_of_http : http -> Sexplib0.Sexp.t
val http_of_sexp : Sexplib0.Sexp.t -> http
val __http_of_sexp__ : Sexplib0.Sexp.t -> http
type json_error = {
  1. message : string;
  2. body : string;
}

An error type indicating a json parse error.

val sexp_of_json_error : json_error -> Sexplib0.Sexp.t
val json_error_of_sexp : Sexplib0.Sexp.t -> json_error
type json = [
  1. | `Json_parse_error of json_error
]

Json level error conditions.

val sexp_of_json : json -> Sexplib0.Sexp.t
val json_of_sexp : Sexplib0.Sexp.t -> json
val __json_of_sexp__ : Sexplib0.Sexp.t -> json
type detail = {
  1. reason : string;
  2. message : string;
}

Used to provide more details on a particular error condition

val detail_to_yojson : detail -> Yojson.Safe.t
val detail_of_yojson : Yojson.Safe.t -> detail Ppx_deriving_yojson_runtime.error_or
val sexp_of_detail : detail -> Sexplib0.Sexp.t
val detail_of_sexp : Sexplib0.Sexp.t -> detail
type response = [
  1. | `Error of detail
]

Application level error conditions

val sexp_of_response : response -> Sexplib0.Sexp.t
val response_of_sexp : Sexplib0.Sexp.t -> response
val __response_of_sexp__ : Sexplib0.Sexp.t -> response
type post = [
  1. | http
  2. | json
  3. | response
]

Any error condition possible from an http post request

val sexp_of_post : post -> Sexplib0.Sexp.t
val post_of_sexp : Sexplib0.Sexp.t -> post
val __post_of_sexp__ : Sexplib0.Sexp.t -> post