package stdune

  1. Overview
  2. Docs
Dune's unstable standard library

Install

Dune Dependency

Authors

Maintainers

Sources

dune-3.8.0.tbz
sha256=f7e2970bfab99c7766ff1a05deff5ad7f82cb2471abca6f72449572293f5f6b4
sha512=3b3a566f63842c314de2c0a660c5f7714bc90f8303c82d82e3021aee84980eff1886d15c9b9d4ea0047a411d799fb39d5f2ea70a92bdeb629e00d3d5d5f2d994

doc/src/stdune/code_error.ml.html

Source file code_error.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
type t =
  { message : string
  ; data : (string * Dyn.t) list
  ; loc : Loc0.t option
  }

exception E of t

let create ?loc message data = { message; data; loc }

let raise ?loc message data = raise (E { message; data; loc })

let dyn_fields_without_loc { loc = _; message; data } =
  [ Dyn.String message; Record data ]

let to_dyn_without_loc t : Dyn.t = Tuple (dyn_fields_without_loc t)

let to_dyn t : Dyn.t =
  let fields = dyn_fields_without_loc t in
  let fields =
    match t.loc with
    | None -> fields
    | Some loc -> Loc0.to_dyn loc :: fields
  in
  Tuple fields

let () =
  Printexc.register_printer (function
    | E t -> Some (Dyn.to_string (to_dyn t))
    | _ -> None)
OCaml

Innovation. Community. Security.