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§
Sourcefn unless_not_found(self) -> Result<Option<T>, CallError>
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".