package fmlib_browser

  1. Overview
  2. Docs

Source file assert_failure.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
31
open Fmlib_js.Base.Main

let attempt (str: string) (f: unit -> 'a) (cleanup: unit -> unit): 'a =
    try
        f ()
    with
    | Assert_failure (file, line, col) ->
        let msg =
            String.concat
                ""
                ["assertion failed file: "
                ; file
                ; " line: "; string_of_int line
                ; " col: ";   string_of_int col
                ]
        in
        cleanup ();
        log_string str;
        log_string msg;
        raise_js str

    | exn ->
        cleanup ();
        log_string str;
        match of_exception exn with
        | None ->
            log_string "Uncaught ocaml exception";
            raise exn
        | Some js_error ->
            log_string "Uncaught javascript exception";
            raise_js_error js_error
OCaml

Innovation. Community. Security.