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#
fn parse(s: str): int!str = int.parse(s)?Fixed#
fn parse(s: str): int! = int.parse(s)?Common causes#
- Using a string or struct as the error type: write
T!andfail("message"). - Declare
enum ParseErr { Empty, Bad(at: int) }for errors callers should match.