Error codes

E0247: ? can't convert this error type

In a terminal: auk explain E0247 prints this page.

On this page

A T!F function can only fail with F values, so ? can't pass up an error of a different enum E. A plain T! function accepts any error (it converts to Err).

Wrong#

auk
enum ReadErr { Missing }
enum AppErr { Bad }
fn read(): int!ReadErr = 1
fn run(): int!AppErr {
  let x = read()?
  x
}

Fixed#

auk
enum ReadErr { Missing }
enum AppErr { Bad }
fn read(): int!ReadErr = 1
fn run(): int!AppErr {
  let x = read() else e => fail(Bad)
  x
}

Common causes#

  • Two layers with their own error enums: map one to the other with else e => fail(...).
  • If callers don't need to match the error, return plain T!.

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