mule/exceptions
The typed analogs of Oban’s exception structs (exceptions.ex) plus the
error kind/stacktrace vocabulary they travel with. A leaf module —
executor, producer, rescue, and telemetry all share this vocabulary, so it
must import nothing from them.
Types
Mirrors the exception structs in Oban’s exceptions.ex, plus the
unknown-worker case Elixir represents as a bare RuntimeError from
Worker.from_string/1.
pub type ExecutionError {
PerformError(worker: String, reason: String)
CrashError(kind: Kind, reason: String)
TimeoutError(worker: String, timeout: Int)
UnknownWorkerError(worker: String)
}
Constructors
-
PerformError(worker: String, reason: String)Oban.PerformError — the worker returned Failed / Cancelled / Discarded.
-
CrashError(kind: Kind, reason: String)Oban.CrashError — an unhandled crash, exit, or throw during perform.
-
TimeoutError(worker: String, timeout: Int)Oban.TimeoutError — the worker’s timer fired before perform returned.
-
UnknownWorkerError(worker: String)worker_registry.lookupmiss (Elixir: Worker.from_string RuntimeError).
How an error arose, mirroring Oban’s kind: a rescued raise is
KindError, a caught exit/1 or exit signal is KindExit, a caught
throw is KindThrow. (Elixir’s {:EXIT, pid} DOWN kind is normalized
to :exit at emit time; this port uses KindExit directly.)
pub type Kind {
KindError
KindExit
KindThrow
}
Constructors
-
KindError -
KindExit -
KindThrow
Formatted stacktrace frames, one line per frame (the typed stand-in for
Exception.stacktrace(); raw terms are unrepresentable in Gleam).
pub type Stacktrace =
List(String)
The %{kind, reason, stacktrace} map Oban carries on job.unsaved_error.
pub type UnsavedError {
UnsavedError(
kind: Kind,
reason: ExecutionError,
stacktrace: List(String),
)
}
Constructors
-
UnsavedError( kind: Kind, reason: ExecutionError, stacktrace: List(String), )
Values
pub fn format(unsaved: UnsavedError) -> String
Exception.format/3 analog: banner plus indented stacktrace lines.
This is the string persisted into the errors column.
pub fn format_banner(kind: Kind, error: ExecutionError) -> String
Exception.format_banner/3 analog: “** (error|exit|throw)