Cairo Panic
Overview
Explain how panics work in Cairo, how to trigger them, and how to constrain panic behavior.
Quick Use
- •Read
references/panic.mdbefore answering. - •Choose the smallest panic API that fits the error message you need.
- •Mention
nopanicrequirements when a caller demands panic-free code.
Response Checklist
- •Use
panicfor array-based errors,panic_with_felt252for a single felt, andpanic!for strings. - •Note that panic unwinds, drops variables, and squashes dictionaries.
- •Use
#[panic_with(...)]for wrapper functions that panic onNoneorErr.
Example Requests
- •"How do I panic with a short error code?"
- •"What does
nopanicmean?" - •"How do I create a wrapper that panics on
None?"