@ @error
@error
Applies to: data, enum
Section: §6.5
Syntax
Attr = "@" Path [ "(" [ AttrArgs ] ")" ] ;Grammar: App. A
Defined in
- 6.5 Errors — There are no exceptions.
- 16.3 gRPC and protobuf — import proto "payments.proto" generates an extern service and types; calls are as to ordinary services through connect.
Examples
@error data NotFound { what: str }
@error enum PayError { Declined(reason: str), Fraud }
fn charge(card: Card, sum: Money) -> Receipt | PayError | NetError net {
let token = Vault.tokenize(card)? // ? propagates the errors of the call
if sum <= Money.zero() { fail PayError.Declined("zero sum") }
Bank.pay(token, sum)
}Related diagnostics
fail-type, question-context, unhandled-error, import-skip