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.Interceptor
NewInterceptor creates a Connect RPC 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-4), the original message is preserved. For unmapped errors (5), the message is sanitized to hide internal details.
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.