package caqti

  1. Overview
  2. Docs
Unified interface to relational database libraries

Install

Dune Dependency

Authors

Maintainers

Sources

caqti-v1.1.0.tbz
md5=1dbae4092760be0813823a1936dec1c6
sha256=9635da1efb377fc4477a573f8292d4afd781e20dae17e2da7250dc7fbfec5170

doc/caqti/Caqti_error/index.html

Module Caqti_errorSource

Error descriptors.

Error Messages

Sourcetype msg = ..

In this type, drivers can stash information about an errors in ther own format, which can later be used for pretty-printing and or future operations. Drivers must define_msg on each constructor added to this type.

Sourceval define_msg : pp:(Format.formatter -> msg -> unit) -> extension_constructor -> unit

Mandatory registration of pretty-printer for a driver-supplied error descriptor.

Sourceval pp_msg : Format.formatter -> msg -> unit

pp_msg ppf msg formats msg on ppf.

Sourcetype msg +=
  1. | Msg : string -> msg
    (*

    The shape of locally generated messages and messages from drivers without dedicated error type.

    *)

Error Records

Note. Please consider the fields internal for now, they may still be revised or hidden.

Sourcetype load_error = private {
  1. uri : Uri.t;
  2. msg : msg;
}
Sourcetype connection_error = private {
  1. uri : Uri.t;
  2. msg : msg;
}
Sourcetype query_error = private {
  1. uri : Uri.t;
  2. query : string;
  3. msg : msg;
}
Sourcetype coding_error = private {
  1. uri : Uri.t;
  2. typ : Caqti_type.any;
  3. msg : msg;
}

Errors during Driver Loading

Sourceval load_rejected : uri:Uri.t -> msg -> [> `Load_rejected of load_error ]

load_rejected ~uri msg indicates that the driver to load could not be identified from uri.

Sourceval load_failed : uri:Uri.t -> msg -> [> `Load_failed of load_error ]

load_failed ~uri msg indicates that a driver for uri could not be loaded.

Errors during Connect

Sourceval connect_rejected : uri:Uri.t -> msg -> [> `Connect_rejected of connection_error ]

connect_rejected ~uri msg indicates that the driver rejected the URI.

Sourceval connect_failed : uri:Uri.t -> msg -> [> `Connect_failed of connection_error ]

connect_failed ~uri msg indicates that the driver failed to establish a connection to the database.

Errors during Call

Sourceval encode_missing : uri:Uri.t -> field_type:'a Caqti_type.field -> unit -> [> `Encode_rejected of coding_error ]

encode_missing ~uri ~field_type () indicates that the driver does not support field_type and no fallback encoding is available for the type.

Sourceval encode_rejected : uri:Uri.t -> typ:'a Caqti_type.t -> msg -> [> `Encode_rejected of coding_error ]

encode_rejected ~uri ~typ msg indicates that encoding a value to typ failed, e.g. due to being out of range.

Sourceval encode_failed : uri:Uri.t -> typ:'a Caqti_type.t -> msg -> [> `Encode_failed of coding_error ]

encode_failed ~uri ~typ msg indicates that a parameter of type typ was not accepted by the database driver.

Sourceval request_rejected : uri:Uri.t -> query:string -> msg -> [> `Request_rejected of query_error ]

request_rejected ~uri ~query msg indicates that query was not accepted by the database or driver.

Sourceval request_failed : uri:Uri.t -> query:string -> msg -> [> `Request_failed of query_error ]

request_failed ~uri ~query msg indicates that the request to could not be transmitted to the database, that the database was not ready to process the request, or that something went wrong while the request was being processed.

Errors during Result Retrieval

Sourceval decode_missing : uri:Uri.t -> field_type:'a Caqti_type.field -> unit -> [> `Decode_rejected of coding_error ]

decode_missing ~uri ~field_type () indicates that the driver does not support field_type for decoding result rows.

Sourceval decode_rejected : uri:Uri.t -> typ:'a Caqti_type.t -> msg -> [> `Decode_rejected of coding_error ]

decode_rejected ~uri ~typ msg indicates that the driver could not decode a field of type typ from the returned row, e.g. due to an invalid value or limited range of the target type.

Sourceval response_failed : uri:Uri.t -> query:string -> msg -> [> `Response_failed of query_error ]

response_failed ~uri ~query msg indicates that something when wrong while fetching a delayed part of the response.

Sourceval response_rejected : uri:Uri.t -> query:string -> msg -> [> `Response_rejected of query_error ]

response_rejected ~uri ~query msg indicates that the response from the database was rejected due to requirements posed by client code.

Error Sub-Types

Sourcetype call = [
  1. | `Encode_rejected of coding_error
  2. | `Encode_failed of coding_error
  3. | `Request_rejected of query_error
  4. | `Request_failed of query_error
  5. | `Response_rejected of query_error
]
Sourcetype retrieve = [
  1. | `Decode_rejected of coding_error
  2. | `Response_failed of query_error
  3. | `Response_rejected of query_error
]
Sourcetype call_or_retrieve = [
  1. | call
  2. | retrieve
]
Sourcetype transact = [
  1. | call
  2. | retrieve
]
Sourcetype load = [
  1. | `Load_rejected of load_error
  2. | `Load_failed of load_error
]
Sourcetype connect = [
  1. | `Connect_rejected of connection_error
  2. | `Connect_failed of connection_error
  3. | `Post_connect of call_or_retrieve
]
Sourcetype load_or_connect = [
  1. | load
  2. | connect
]

Error Type and Functions

Sourcetype t = [
  1. | load
  2. | connect
  3. | call
  4. | retrieve
]

The full union of errors used by Caqti.

Sourceval uri : [< t ] -> Uri.t

uri error is the URI of the connection used where error occurred.

Sourceval pp : Format.formatter -> [< t ] -> unit

pp ppf error prints an explanation of error on ppf.

Sourceval show : [< t ] -> string

show error is an explanation of error.

Sourceexception Exn of t

Exn error can be used when an exception is preferred over explicit error handling. The core Caqti API never raises exceptions which originate from runtime errors.

OCaml

Innovation. Community. Security.