Skip to content

Commit

Permalink
teach Printexc how to print BCH_failure exceptions
Browse files Browse the repository at this point in the history
without this, we get cryptic error messages like:
BCHBasicTypes.BCH_failure(_)

which is not very useful for debugging. With this change, we get something like:
Alignof error: tvoid
which is more greppable ;-)
  • Loading branch information
waskyo authored and sipma committed May 3, 2024
1 parent 94dc1ea commit def915e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions CodeHawk/CHB/bchlib/bCHBCTypeUtil.ml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ open BCHBCFiles
open BCHBCTypePretty
open BCHBCTypes

let string_printer = CHPrettyUtil.string_printer
let p2s = string_printer#print

(* Teach Printexc how to print our own exceptions *)
let () =
Printexc.register_printer
(function
| BCH_failure e -> Some (p2s(e))
| _ -> None (* for other exceptions *)
)

(* ====================================================== common scalar types *)

Expand Down

0 comments on commit def915e

Please sign in to comment.