Skip to content
beskid The Beskid Book

Beskid

Jump to a Beskid service

Beskid

Jump to a Beskid service

09.4 Panic vs contract

When the runtime traps, when contracts fail at compile time, and how FFI keeps worlds apart.

Panic vs contract

Contract failure is a compile-time diagnostic: you fix the type or member before shipping.

Panic is a runtime trap for invariant violations, failed host assumptions, or policy-defined unwinds at boundaries, not a replacement for Result.

Missing Dispose() on Disposable? E1601, not a stack trace in prod. That is the point of structural contracts (Contracts).

Execution owns panic bridges and syscall surfaces:

Normative gist: Beskid panic must not assume foreign callers catch Rust/Beskid unwinds. Profiles define who may translate traps.

MechanismUse for
Result / ?Expected failures (parse errors, missing files, domain rules)
test assertionsHarness failures with structured runner output
Panic / trapBug, violated invariant, host abort

Do not catch panic in application Beskid as if it were Java. If you need control flow, use Result.

Analyzer mods emit diagnostics and fixes; they do not throw into your runtime. Host merge either accepts typed rewrites or fails closed (Mod host bridge).

10. Memory without another billion-dollar mistake