-
Notifications
You must be signed in to change notification settings - Fork 415
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This new code_error exception uses Dyn.t rather than Sexp.t Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
- Loading branch information
Showing
9 changed files
with
74 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module Dyn = Dyn0 | ||
|
||
type t = | ||
{ message : string | ||
; data : (string * Dyn.t) list | ||
} | ||
|
||
exception E of t | ||
|
||
let raise message data = | ||
raise (E { message; data }) | ||
|
||
let to_dyn { message; data } : Dyn.t = | ||
Tuple | ||
[ String message | ||
; Record data | ||
] | ||
|
||
let () = | ||
Printexc.register_printer (function | ||
| E t -> Some (Dyn.to_string (to_dyn t)) | ||
| _ -> None) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
(** A programming error that should be reported upstream *) | ||
|
||
type t = | ||
{ message : string | ||
; data : (string * Dyn0.t) list | ||
} | ||
|
||
exception E of t | ||
|
||
val to_dyn : t -> Dyn0.t | ||
|
||
val raise : string -> (string * Dyn0.t) list -> _ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,3 +100,5 @@ and pp_sexp = function | |
] | ||
|
||
let pp fmt t = Pp.pp fmt (pp t) | ||
|
||
let to_string t = Format.asprintf "%a" pp t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters