package yocaml

  1. Overview
  2. Docs

Describes the list of errors that can occur in the process of creating a blog.

Errors list

The type of errors could be "open", but I find it quite comfortable to locate the errors in one place to easily provide conversion and manipulation functions. In addition, it allows me to generalize the type of Result and Validation without relying on exceptions.

type t =
  1. | List of t Preface.Nonempty_list.t
    (*

    Groups several errors into one (mainly to ensure conversions between Try and Validate).

    *)
  2. | Labelled_list of string * t Preface.Nonempty_list.t
  3. | Unix of string * string * string
    (*

    Unix related error.

    *)
  4. | Unreadable_file of string
    (*

    When a file is unreadable.

    *)
  5. | Missing_field of string
  6. | Invalid_field of string
  7. | Invalid_metadata of string
  8. | Required_metadata of string list
  9. | Yaml of string
  10. | Mustache of string
  11. | Invalid_date of string
  12. | Invalid_year of int
  13. | Invalid_day of int
  14. | Invalid_month of int
  15. | Invalid_range of int * int * int
  16. | Unknown of string
    (*

    An unq\ualified error (probably due to laziness).

    *)
  17. | Message of string
exception Error of t

Represents an Error.t in exception.

Conversions

val to_string : t -> string

Use pp to convert an Error.t to a string.

val to_exn : t -> exn

Converts an Error.t into an exception.

val to_try : t -> ('a, t) Preface.Result.t

Converts an Error.t into a Preface.Result.t.

val to_validate : t -> ('a, t Preface.Nonempty_list.t) Preface.Validation.t

Converts an Error.t into a Preface.Validation.t.

Actions

val raise' : t -> 'a

Raises an Error.t as an exception.

Helpers

val pp : Stdlib.Format.formatter -> t -> unit

Pretty-printers for Error.t.

val equal : t -> t -> bool

Equality betweens Error.t.

OCaml

Innovation. Community. Security.