panic

extern fn panic(data: Array<felt252>) -> never;
Triggers an immediate panic with the provided data and terminates execution. This function is the core panic mechanism in Cairo. When called, it:
  1. Takes an array of felt252 values as panic data
  2. Terminates the current execution
  3. Propagates the panic data up the call stack

Parameters

  • data: Array<felt252> - The panic data to be included with the panic

Returns

  • never - This function never returns as it terminates execution

Example

use core::panics::panic;

// Panic with custom data
panic(array!['Error code', 42, 'Additional info']);