Module JavaException

module JavaException: sig .. end
Utility functions for Java exceptions.

Instance creation

type t = java'lang'Exception java_instance
The type of exceptions.
val make : ?cause:t -> ?message:JavaString.t -> unit -> t
Returns a new java.lang.Exception instance; see Exception(...).


val throw : t -> 'a
Synonym for Java.throw.

Base methods

val get_cause : t -> java'lang'Throwable java_instance
Returns the case; see getCause(...).
val get_message : t -> JavaString.t
Returns the message; see getMessage(...).
val get_stack_trace : t ->
java'lang'StackTraceElement java_instance java_reference_array
Returns the stack trace; see getStackTrace(...).
val print_stack_trace : t -> unit
Returns the stack trace; see printStackTrace(...).

Null value

val null : t
The null value.
val is_null : t -> bool
is_null obj returns true iff obj is equal to null.
val is_not_null : t -> bool
is_not_null obj returns false iff obj is equal to null.


val wrap : t -> t option
wrap obj wraps the reference obj into an option type:
  • Some x if obj is not null;
  • None if obj is null.

val unwrap : t option -> t
unwrap obj unwraps the option obj into a bare reference:
  • Some x is mapped to x;
  • None is mapped to null.