Module envoy_sdk::error[][src]

The Error type and helpers.

Examples

use envoy::error::{bail, Result};

fn on_request() -> Result<()> {
    // ...
    bail!("unexpected state");
}
use envoy::error::{ensure, Result};

fn on_request() -> Result<()> {
    ensure!(body_len != 0, "request body must not be empty");
    // ...
}
use envoy::error::{format_err, Result};

fn on_request() -> Result<()> {
    if method == "DELETE" {
        return Err(format_err!("{} method is not allowed", method));
    }
    // ...
}
use envoy::error::{ErrorContext, Result};
use envoy::host::Clock;

fn on_request() -> Result<()> {
    let now = Clock::default().now()
        .with_context(|| format!("Failed to get time of the request {}", instance_id))?;
    // ...
}

Macros

bail

Return early with an error.

ensure

Return early with an error if a condition is not satisfied.

format_err

Construct an ad-hoc error from a string or existing non-anyhow error value.

Structs

Error

The Error type, a wrapper around a dynamic error type.

Traits

ErrorContext

Provides the context method for Result.

Type Definitions

Result

Result<T, Error>