A helper trait to assist with passing error types through return tonic::Status
messages.
Usage
This works with the thiserror crates, but using that is not required. If you
are not using thiserror then at the moment you will need to manually implement
std::fmt::Display for your type. Your error type will also need to derive
serde::{Serialize, Deserialize}.
In order to use this, you will need to #[derive(TonicError)] on your error type.
The TonicError trait provides implementations of std::convert::TryFrom for
your type, and an implementation of std::convert::From for tonic::Status.
These examples are taken from the included examples.
Server Side
async
Client Side
pub async
Example
See the tonic-error-example subdirectory in this repo for a working
client/server example.
License
This is released under the Apache 2.0 license.