Skip to content

Commit

Permalink
Break compatibility to wrap modules
Browse files Browse the repository at this point in the history
This module does not seem to be used by public libraries on opam.
I don't think this will break a lot of foreign code.
  • Loading branch information
mlasson committed Dec 22, 2020
1 parent ade3336 commit 84d6c64
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 39 deletions.
1 change: 0 additions & 1 deletion lib/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
(public_name ojs)
(synopsis "Runtime support for gen_js_api")
(libraries)
(wrapped false)
(foreign_stubs (language c) (names ojs_runtime_stubs))
(modes byte)
(js_of_ocaml (javascript_files ojs_runtime.js)))
23 changes: 23 additions & 0 deletions lib/ojs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,26 @@ let is_null x =

let obj_type x =
string_of_js (call (pure_js_expr "Object.prototype.toString") "call" [|x|])

module Exn = struct
type nonrec t = t

let name x = string_of_js (get x "name")
let message x = string_of_js (get x "message")
let stack x = option_of_js string_of_js (get x "stack")
let to_string x = string_of_js (call x "toString" [||])

exception Error of t

let () = Callback.register_exception "jsError" (Error (obj [||]))

(* The js_of_ocaml runtime expects to have this registered.
So it's probably a bad idea to use both this Ojs.Exn module
and the js_of_ocaml standard library. *)

let () =
Printexc.register_printer (function
| Error x -> Some (to_string x)
| _ -> None
)
end
14 changes: 14 additions & 0 deletions lib/ojs.mli
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,17 @@ val obj_type: t -> string
"[object Null]"
"[object Boolean]"
*)

module Exn : sig
(** OCaml view on JS exceptions *)

type t

val name: t -> string
val message: t -> string
val stack: t -> string option
val to_string: t -> string

exception Error of t

end
24 changes: 0 additions & 24 deletions lib/ojs_exn.ml

This file was deleted.

14 changes: 0 additions & 14 deletions lib/ojs_exn.mli

This file was deleted.

0 comments on commit 84d6c64

Please sign in to comment.