Error codes

E0112: the error type of T!E must be an enum

In a terminal: auk explain E0112 prints this page.

On this page

In T!E, E lists the ways a function can fail, so it must be an enum whose variants callers can match. For an untyped error with a message, write plain T!.

Wrong#

auk
fn parse(s: str): int!str = int.parse(s)?

Fixed#

auk
fn parse(s: str): int! = int.parse(s)?

Common causes#

  • Using a string or struct as the error type: write T! and fail("message").
  • Declare enum ParseErr { Empty, Bad(at: int) } for errors callers should match.

Stuck on a word? Try the glossary. Got a compiler error? Look up its code. Improve this page