errors

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2026 License: MIT Imports: 1 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ErrParseError      = -32700
	ErrInvalidRequest  = -32600
	ErrMethodNotFound  = -32601
	ErrInvalidParams   = -32602
	ErrInternalError   = -32603
	ErrUnauthorized    = -32001
	ErrForbidden       = -32003
	ErrNotFound        = -32004
	ErrTimeout         = -32008
	ErrConflict        = -32009
	ErrTooManyRequests = -32029
)

tRPC error codes (TRPC_ERROR_CODES_BY_KEY)

View Source
const ErrBadRequest = ErrInvalidRequest

ErrBadRequest is an alias for ErrInvalidRequest. Both map to tRPC code -32600. Use ErrBadRequest for application-level validation errors; ErrInvalidRequest for protocol-level errors.

Variables

This section is empty.

Functions

func CodeName

func CodeName(code int) string

CodeName returns the string name for a tRPC error code.

func HTTPStatus

func HTTPStatus(code int) int

HTTPStatus returns the HTTP status code for a tRPC error code.

Types

type TRPCError

type TRPCError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Cause   error  `json:"-"` // original error for logging; never sent to client
}

TRPCError represents a tRPC-compatible error.

func New

func New(code int, message string) *TRPCError

New creates a new TRPCError with the given code and message.

func Newf

func Newf(code int, format string, args ...interface{}) *TRPCError

Newf creates a new TRPCError with a formatted message.

func Wrap

func Wrap(err error, code int, message string) *TRPCError

Wrap creates a TRPCError that wraps an underlying error. The cause is preserved for logging but never sent to the client.

func Wrapf

func Wrapf(err error, code int, format string, args ...interface{}) *TRPCError

Wrapf creates a TRPCError that wraps an underlying error with a formatted message.

func (*TRPCError) Error

func (e *TRPCError) Error() string

func (*TRPCError) Unwrap

func (e *TRPCError) Unwrap() error

Unwrap returns the underlying cause, enabling errors.Is and errors.As.

Jump to

Keyboard shortcuts

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