libero/trace

Panic-catching + trace_id primitives for the dispatch layer.

try_call(action) runs a zero-arg function inside an Erlang try/catch and returns Ok(result) on success or Error(reason) where reason is the stringified exception.

new_trace_id() returns a 12-character base16-encoded random id, suitable for correlating log lines with RPC error responses.

Logging is intentionally not part of this module. Libero stays free of wisp/logging dependencies so it can be used in any Erlang-target consumer. The generated dispatch code uses io.println_error as a default logger; consumers that want structured logging can wrap the primitives in their own module.

Values

pub fn new_trace_id() -> String

Generate a fresh 12-character base16 random id. 6 bytes of entropy is plenty for log correlation and keeps the id short enough to fit in a devtools view.

pub fn try_call(action: fn() -> a) -> Result(a, String)

Run the given function, catching any panic. Returns the result on success; on failure, returns the stringified exception reason. Callers typically pair this with a trace id from new_trace_id and log both under a single correlation id.

Search Document