0Pricing
Mojo Academy · Lesson

Raising an Error

Signal that something went wrong.

When Things Go Wrong

Sometimes a function hits a situation it cannot handle, like a missing file or bad input. Mojo lets you signal that with an error. ⚠️

The raise Keyword

To signal a failure, you use the raise keyword. It stops the current work and reports that something went wrong.

raise Error("something went wrong")

All lessons in this course

  1. Raising an Error
  2. Catching with try/except
  3. The raises Annotation
  4. Cleanup with finally
← Back to Mojo Academy