errors

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 15, 2025 License: MIT Imports: 3 Imported by: 0

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:

  1. context.Canceled → CodeCanceled
  2. context.DeadlineExceeded → CodeDeadlineExceeded
  3. ConnectCoder interface → code from ConnectCode()
  4. *connect.Error → preserved as-is
  5. 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

type ConnectCoder interface {
	ConnectCode() connect.Code
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL