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

error unhandled-error

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

Результат с ошибкой проигнорирован.

What it means#

A union type that contains an @error type is a result with an error and cannot be discarded (§3.5, §6.5). An expression statement whose type contains an error type is a compile-time error. Handle it with match, ?, !>, if ... is, bind it to a variable that is then handled, or discard explicitly with _ = e.

Example#

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

fn charge(sum: i64) -> i64 | Declined => sum

fn main() {
  charge(10)      // <- unhandled-error
}
error
unhandled-error

How to fix#

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

fn charge(sum: i64) -> i64 | Declined => sum

fn pay() -> () | Declined {
  let paid = charge(10)?
  print("{paid}")
}

Propagate with ? (the error type must be part of the return type), match on the result, or write _ = charge(10) if ignoring really is intended.

See also#

См. также

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