tonic icon indicating copy to clipboard operation
tonic copied to clipboard

feat(tonic): add From<BoxError> implementation for tonic::transport::Error

Open gabotechs opened this issue 4 months ago • 2 comments

Addresses https://github.com/hyperium/tonic/issues/978

This PR keeps the tonic::transport::Error constructor methods private while allowing external users to map BoxErrors into tonic::transpoert::Error, which makes it possible to do something like:

fn test() -> Result<(), crate::transport::Error> {
    let err = Err(crate::BoxError::from("test"));
    err?;
    Ok(())
}

More details about why users would want to build tonic::transport::Error in the issue.

Also, completely open to alternatives.

gabotechs avatar Aug 21 '25 06:08 gabotechs

What is the use case here, its not construct-able publicly for a reason.

LucioFranco avatar Aug 22 '25 14:08 LucioFranco

What is the use case here, its not construct-able publicly for a reason.

this comment explains it: https://github.com/hyperium/tonic/issues/978#issuecomment-3209208871

gabotechs avatar Aug 22 '25 14:08 gabotechs