1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
type t =
| Io_error of string
| Format_error of string
| Unsupported_dtype
| Unsupported_shape
| Missing_entry of string
| Other of string
let to_string = function
| Io_error msg -> Printf.sprintf "I/O error: %s" msg
| Format_error msg -> Printf.sprintf "Format error: %s" msg
| Unsupported_dtype -> "Unsupported dtype"
| Unsupported_shape -> "Unsupported shape"
| Missing_entry name -> Printf.sprintf "Missing entry: %s" name
| Other msg -> msg
let fail_msg fmt =
Printf.ksprintf
(fun s ->
let msg = Format.asprintf "Error: %s\n%!" s in
failwith msg)
fmt