Documentation
¶
Overview ¶
Package errors provides error mapping for Connect RPC handlers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewInterceptor ¶
func NewInterceptor() connect.ServerInterceptor
NewInterceptor creates a Connect RPC server interceptor that maps errors to appropriate Connect codes.
Error mapping priority:
- context.Canceled → CodeCanceled
- context.DeadlineExceeded → CodeDeadlineExceeded
- ConnectCoder interface → code from ConnectCode()
- *connect.Error → preserved as-is
- Any other error → CodeInternal with message "internal error"
For mapped errors (1-3), the original message is sent to the client. For unmapped errors (5), the message is sanitized to hide internal details. The original error stays available to errors.Is and errors.As as the cause.
Types ¶
type ConnectCoder ¶
ConnectCoder allows errors to specify their Connect RPC error code. Implement this interface on domain errors to map them to appropriate Connect codes while preserving the original error message.
Click to show internal directories.
Click to hide internal directories.