OxL Справочник OxL
РусскийEnglish

error fail-type

error Стандарт: [§6.5]

Тип ошибки не входит в возвращаемый тип функции.

What it means#

fail e returns the error e from the function, so the type of e MUST be part of the declared return type; the same holds for errors propagated with e? (§6.5). The return type must be a union that mentions the error type explicitly.

Example#

oxl✓ проверяется в CI
@error data NotFound { what: str }

fn find(id: u64) -> str | NotFound {
  fail Timeout      // <- fail-type
}
error
fail-type

How to fix#

oxl✓ проверяется в CI
@error data NotFound { what: str }

fn find(id: u64) -> str | NotFound {
  fail NotFound{ what: "user" }
}

Fail with an error from the declared set, or extend the return type (-> str | NotFound | Timeout).

See also#

OxL 1.0.0-beta · Версия документации 1.0.0-beta© OxwaldLink · сгенерировано из Стандарта, исходников std и руководства