pub fn domain_to_connect<E>(err: &E) -> ConnectErrorwhere
E: IntoDomainErrorKind,Expand description
Map any domain error implementing IntoDomainErrorKind to a ConnectError.
Variant mapping:
DomainErrorKind | ConnectError |
|---|---|
NotFound | not_found("not found") |
Conflict(msg) | already_exists(msg) |
Internal(detail) | internal("internal error") — detail logged, not surfaced |
Internal errors are logged at ERROR level before the ConnectError is
returned. The detail string is never forwarded to callers.
§Example
use api_bones::connect::{DomainErrorKind, IntoDomainErrorKind, domain_to_connect};
use connectrpc::ConnectError;
struct NotFoundErr;
impl IntoDomainErrorKind for NotFoundErr {
fn kind(&self) -> DomainErrorKind { DomainErrorKind::NotFound }
}
let err: ConnectError = domain_to_connect(&NotFoundErr);