#[derive(GrpcError)]
{
// Attributes available to this derive:
#[grpc]
}
Expand description
Derive macro for automatic gRPC status conversion
Generates From<Error> for tonic::Status implementation.
Use #[grpc(CODE)] on variants to specify the gRPC status code.
§Example
ⓘ
use allframe_macros::GrpcError;
use thiserror::Error;
#[derive(Error, Debug, GrpcError)]
pub enum AppError {
#[error("Unauthenticated: {0}")]
#[grpc(UNAUTHENTICATED)]
Unauthenticated(String),
#[error("Rate limited")]
#[grpc(RESOURCE_EXHAUSTED)]
RateLimited,
#[error("Not found: {0}")]
#[grpc(NOT_FOUND)]
NotFound(String),
#[error("Internal error: {0}")]
#[grpc(INTERNAL)]
Internal(String),
}
// Auto-generates: impl From<AppError> for tonic::Status§Supported gRPC Codes
OK,CANCELLED,UNKNOWN,INVALID_ARGUMENTDEADLINE_EXCEEDED,NOT_FOUND,ALREADY_EXISTSPERMISSION_DENIED,RESOURCE_EXHAUSTED,FAILED_PRECONDITIONABORTED,OUT_OF_RANGE,UNIMPLEMENTED,INTERNALUNAVAILABLE,DATA_LOSS,UNAUTHENTICATED