tur/panic
stdlib/panic.tur
inspect panics recovered by catch-unwind.
Since: Phase R2
defopaque
Panic
(Panic)
defn
result-panic
(result-panic [r : int] :)
extract the Panic handle from a caught (err ...) result.
Parameters
| r | the :int result box returned by catch-unwind / catch-panic-of |
Returns
The opaque Panic handle from the err slot (0 when r is ok).
Example
(let [r (catch-unwind (fn [] :int (panic "boom")))]
(panic-message (result-panic r))) ; => "boom"
Since: Phase R2
defn
panic-message
(panic-message [p : Panic] :)
the message string carried by a caught Panic.
Parameters
| p | a Panic handle (see result-panic) |
Returns
The panic message for a string panic, or "" when none is available.
Since: Phase R2
defn
panic-file
(panic-file [p : Panic] :)
source file of the panic call site.
Parameters
| p | a Panic handle |
Returns
The source file path, or "" when unknown.
Since: Phase R2
defn
panic-line
(panic-line [p : Panic] :)
source line of the panic call site.
Parameters
| p | a Panic handle |
Returns
The source line, or 0 when unknown.
Since: Phase R2
defn
panic-type
(panic-type [p : Panic] :)
the TypeKind tag of the panic payload.
Parameters
| p | a Panic handle |
Returns
The integer TypeKind of the boxed payload (e.g. the tag for :cstr for a plain string panic), or 0 when unknown.
Since: Phase R2