Skip to main content

domain_to_connect

Function domain_to_connect 

Source
pub fn domain_to_connect<E>(err: &E) -> ConnectError
Expand description

Map any domain error implementing IntoDomainErrorKind to a ConnectError.

Variant mapping:

DomainErrorKindConnectError
NotFoundnot_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);