package jsont

  1. Overview
  2. Docs

Module Jsont.ErrorSource

Encoding, decoding and query errors.

Kinds of errors

Sourcetype kind

The type for kind of errors.

Sourceval kind_to_string : kind -> string

kind_to_string kind is kind as a string.

Errors

Sourcemodule Context : sig ... end

JSON error contexts.

The type for errors. The context, the error localisation and the kind of error.

Sourceval raise : Context.t -> Meta.t -> kind -> 'a

raise ctx meta k raises an error with given paramters.

Sourceval make_msg : Context.t -> Meta.t -> string -> t

make_msg ctx meta msg is an error with message msg for meta meta in context ctx.

Sourceval msg : Meta.t -> string -> 'a

msg meta msg raises an error with message msg for meta meta in an empty context.

Sourceval msgf : Meta.t -> ('a, Format.formatter, unit, 'b) format4 -> 'a

msgf meta fmt … is like msg but formats an error message.

Sourceval expected : Meta.t -> string -> fnd:string -> 'a

expected meta fmt exp ~fnd is msgf "Expected %s but found %s" exp fnd.

Sourceval push_array : string node -> int node -> t -> 'a

push_array kinded_sort n e contextualises e as an error in the nth element of an array of kinded sort kinded_sort.

Sourceval push_object : string node -> string node -> t -> 'a

push_object kinded_sort n e contextualises e as an error in the member n of an object of kinded sort kinded_sort.

Sourceval adjust_context : first_byte:Textloc.byte_pos -> first_line:Textloc.line_pos -> t -> 'a

adjust_context ~first_byte ~first_line adjusts the error's context's meta to encompass the given positions.

Formatting

Sourceval to_string : t -> string

error_to_string e formats e using pp to a string.

Sourceval pp : t fmt

pp_error formats errors.

Sourceval puterr : unit fmt

puterr formats Error: in red.