Error Handling

In this chapter, we'll explore handle errors gracefully with panic and result.

Error Handling

Errors are a fact of life in software. Mana groups errors into two major categories:

  • Recoverable errors — Like file not found, report and retry
  • Unrecoverable errors — Like accessing beyond array bounds, stop immediately

Most languages don't distinguish between these and use exceptions. Mana doesn't have exceptions. Instead, it has:

  • Result<T, E> for recoverable errors
  • panic! for unrecoverable errors

Let's explore both: