Error Handling
This chapter will be expanded as the error-handling model is finalized.
Rux favors explicit error handling over exceptions: a function that can fail reports the failure in its return type, and the caller must deal with it. Unrecoverable conditions instead abort the program with a fatal error.
| Topic | Description |
|---|---|
The Result Type | Return-type encoding of recoverable errors |
| Fatal Errors | Aborting on unrecoverable conditions |
See Also
match— handling the variants of aResult- Enumerations — the tagged-value mechanism behind
Result
Import
import brings names from a module into the current scope so they can be used without their full path. It comes in three forms:
The Result Type
The standard approach to recoverable errors uses return-type encoding with a Result type. A function that can fail returns Result<T, E>, where T is the success value and E is the error.