You’re reading a draft of the Ferrocene Language Specification. Some parts of this document might be missing, incomplete or incorrect. Our aim is to have the specification ready by the end of 2022.

16. Exceptions and Errors

Legality Rules

16:1 The Rust programming language lacks exceptions and exception handlers. Instead, the language uses the following tiered error handling scheme:

16:5 Enum core::option::Option indicates whether a value is either present using core::option::Option::Some or absent using core::option::Option::None.

16:6 Enum core::result::Result indicates whether a computation completed successfully and produced a value using core::result::Result::Ok or the computation failed with an error using core::result::Result::Err.

16.1. Panic

Legality Rules

16.1:1 A panic is an abnormal program state caused by invoking macro core::panic.

Dynamic Semantics

16.1:2 Invoking macro core::panic has the following runtime effects:

  1. 16.1:3 Control flow halts the execution of the current thread.

  2. 16.1:4 Control flow of the current thread resumes execution by invoking the function subject to attribute panic_handler.

Undefined Behavior

16.1:5 It is undefined behavior when a panic crosses a foreign function interface boundary.


panic!("This was a terrible mistake!");

16.2. Abort

Legality Rules

16.2:1 Abort is the immediate termination of a program.

Dynamic Semantics

16.2:2 Abort has the following runtime effects:

  1. 16.2:3 Control flow halts the execution of all threads.

  2. 16.2:4 The program terminates.