Crate miden_node_grpc_error_macro

Crate miden_node_grpc_error_macro 

Source
Expand description

Procedural macro for deriving the GrpcError trait on error enums.

This macro simplifies the creation of gRPC-compatible error enums by automatically:

  • Generating a companion error enum for gRPC serialization
  • Implementing the GrpcError trait
  • Providing proper error code mappings
  • Generating From<Error> for tonic::Status conversion

§Example

use miden_node_grpc_error_macro::GrpcError;
use thiserror::Error;

#[derive(Debug, Error, GrpcError)]
pub enum GetNoteScriptByRootError {
    #[error("database error")]
    #[grpc(internal)]
    DatabaseError(#[from] DatabaseError),
     
    #[error("malformed script root")]
    DeserializationFailed,
     
    #[error("script with given root doesn't exist")]
    ScriptNotFound,
}

Derive Macros§

GrpcError
Derives the GrpcError trait for an error enum.