Expand description
Catching a panic as a value that names where it began.
A panic turned into an Err at the nearest catch lets the caller’s own
failure path run: the rollback or cleanup it does on Err, which an unwind
would skip. caught catches a panic in a future, and caught_sync in
a synchronous call. Each returns a Bug that holds the text the panic
carried, the operation the work was doing, and the SourceLocation where
the panic began, which a panic’s payload does not hold.
Work nobody waits for hands its bug to a BugSink instead, through
report, and an error that holds a bug says so through CarriesBug.
locks holds the helpers that take a lock whose holder panicked.
Modules§
- locks
- Taking a lock whose holder may have panicked.
Structs§
- Bug
- Work that panicked, or that code found wrong without a panic: a bug in it, not a failure its caller can act on. The caller reports it wherever it reports its own bugs, and the call that ran the work returns it as its error.
- Source
Location - Where in the code a bug showed itself: the file, line and column of the panic, or of the code that found the bug and made it.
Enums§
- BugKind
- How a bug showed itself.
Traits§
- BugSink
- Where a bug in work nobody waits for goes: a long-lived worker, or work whose caller stopped waiting for it. The program passes its own crash reporter.
- Carries
Bug - An error that may carry a bug: work its call ran panicked, and the call’s error says so. Work nobody waits for reports the bug its error carries, as it reports its own panic.
Functions§
- bug_
of_ unlocated - Make the bug for a panic’s
payloadwhen the panic began outside this crate’s catches, so the bug has no location. - catching_
operation - The operation of the innermost catch of this crate’s running on this thread,
or
Noneoutside every one: for the app’s own panic hook, to say what the panicking work was doing. A panic a catch inside that work handles itself, such as a task tokio runs on this thread and catches, still names it. It never panics, so a hook can call it: a panic inside a hook ends the process. - caught
- Run
workinline, catching a panic in any of its polls. For one message of a long-lived loop: the panic fails that message and the loop serves the next. The runtime can’t drop work that runs inline, so a panic is its only failure. - caught_
sync caughtfor a synchronous call: an FFI callback, a dedicated thread’s body, aDrop. Unwinding out of anextern "C"function aborts the process, so such a function catches here and answers with its own failure value.- panic_
message - The text a panic carried: what
panic!andexpectwere given, or a placeholder for a payload that is not text. - report
- Hand
bugtobugs. When the sink panics too,reportlogs that panic and stops it there, because nothing above the sink catches it.
Type Aliases§
- BugSink
Ref - A shared
BugSink.