Js_exn
Provide utilities for dealing with JS exceptions.
t
Represents a JS exception
type t
asJsExn
let asJsExn: exn => option<t>
stack
let stack: t => option<string>
message
let message: t => option<string>
name
let name: t => option<string>
fileName
let fileName: t => option<string>
isCamlExceptionOrOpenVariant
internal use only
let isCamlExceptionOrOpenVariant: 'a => bool
anyToExnInternal
anyToExnInternal obj
will take any value obj
and wrap it
in a Js.Exn.Error if given value is not an exn already. If
obj
is an exn, it will return obj
without any changes.
This function is mostly useful for cases where you want to unify a type of a value that potentially is either exn, a JS error, or any other JS value really (e.g. for a value passed to a Promise.catch callback)
IMPORTANT: This is an internal API and may be changed / removed any time in the future.
switch (Js.Exn.unsafeAnyToExn("test")) { | Js.Exn.Error(v) => switch(Js.Exn.message(v)) { | Some(str) => Js.log("We won't end up here") | None => Js.log2("We will land here: ", v) } }
let anyToExnInternal: 'a => exn
raiseError
Raise Js exception Error object with stacktrace
let raiseError: string => 'a
raiseEvalError
let raiseEvalError: string => 'a
raiseRangeError
let raiseRangeError: string => 'a
raiseReferenceError
let raiseReferenceError: string => 'a
raiseSyntaxError
let raiseSyntaxError: string => 'a
raiseTypeError
let raiseTypeError: string => 'a
raiseUriError
let raiseUriError: string => 'a