Skip to main content

Module errors

Module errors 

Source
Expand description

§Errors

§Purpose

Defines the domain-specific error types for the gateway and utilities for mapping gRPC status codes to HTTP status codes. This module ensures that internal errors and upstream gRPC errors are correctly translated into HTTP responses.

§Scope

This module defines:

  • GatewayError: The primary error type representing failures within the gateway or upstream interactions.
  • map_code_to_status: A utility to convert gRPC Codes to HTTP StatusCodes.
  • handle_error: A utility to construct a JSON error response from a tonic::Status.

§Position in the Architecture

Errors originating from the codec, router, or upstream gRPC calls are captured as GatewayError. The generated code uses handle_error to transform these errors into standard HTTP responses before sending them to the client.

§Design Constraints

  • Dual-Mode Error Handling: When std is enabled, it leverages thiserror for ergonomic error definition. In no_std environments, it falls back to a manual implementation using alloc.

Enums§

GatewayError
Domain-specific errors for the gateway.

Functions§

handle_error
Converts a gRPC status into an HTTP response.
map_code_to_status
Maps a gRPC status code to an HTTP status code.