error unhandled-error
Результат с ошибкой проигнорирован.
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#
@error data Declined { reason: str }
fn charge(sum: i64) -> i64 | Declined => sum
fn main() {
charge(10) // <- unhandled-error
}error
unhandled-error
How to fix#
@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.