Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Error ¶
type Error struct {
Original error
Message string
ErrCode ErrorCode
FieldViolations []*FieldViolation
ErrorDetailsFunc GRPCDetailsFunc
}
Error is the unified application error type. It supports gRPC status details, HTTP status mapping, and validation field violations.
func NewValidationError ¶
func NewValidationError(violations []*FieldViolation, msg ...string) *Error
NewValidationError builds an InvalidArgument error with validation details.
func (*Error) GRPCStatus ¶
GRPCStatus converts the error into a gRPC status, with field or metadata details.
func (*Error) HTTPStatus ¶
HTTPStatus returns a standardized HTTP status code and JSON-safe error body. This is meant to be transport-agnostic, usable across multiple HTTP/REST frameworks.
type FieldViolation ¶
FieldViolation represents a validation field violation.
func BuildViolations ¶
func BuildViolations(verrs validator.ValidationErrors) []*FieldViolation
BuildViolations converts validator.ValidationErrors into []*FieldViolation.
type GRPCDetailsFunc ¶
type GRPCDetailsFunc func(st *status.Status, details ...protoiface.MessageV1) (*status.Status, error)
GRPCDetailsFunc allows customizing how error details are attached to gRPC response. This is particularly useful with gRPC rich error reporting.