Skip to content
fn

Err

→ErrorPayload
ErrorPayload Err(ErrorCode code, int msg)

Builds an ErrorPayload from a code and message.

The returned payload is implicitly convertible to Result<T> for any T, so a return Err(code, msg); inside a function returning Result<Something> Just Works.

Parameters

codeErrorCode
Category of the failure.
msgstd::string
Human-readable message moved into ErrorPayload::msg.

Returns

ErrorPayload

Error descriptor ready to be returned as the failure arm of a Result.

Examples

```
return Err(ErrorCode::IndexOutOfRange, "i must be in [0, n)");
```