Skip to main content

UnlessNotFound

Trait UnlessNotFound 

Source
pub trait UnlessNotFound<T> {
    // Required method
    fn unless_not_found(self) -> Result<Option<T>, CallError>;
}
Expand description

Extension trait that converts a CallError with code ErrCode::NotFound into Ok(None).

ⓘ
use encore::services::UnlessNotFound;

let product = catalog::openapi::get_product("xyz").await.unless_not_found()?;

Required Methods§

Source

fn unless_not_found(self) -> Result<Option<T>, CallError>

Maps Ok(v) to Ok(Some(v)), Err(e) with e.code == ErrCode::NotFound to Ok(None), and leaves all other errors unchanged.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T> UnlessNotFound<T> for Result<T, CallError>

Implementors§