errorsx

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cause

func Cause(err error) error

Cause returns the underlying cause of the error, if possible. An error value has a cause if it implements the following interface:

type causer interface {
       Cause() error
}

If the error does not implement Cause, the original error will be returned. If the error is nil, nil will be returned without further investigation.

func WithStack

func WithStack(err error) error

WithStack mirror pkg/errors.WithStack but does not wrap existing stack traces.

func WriteJSONError

func WriteJSONError(w http.ResponseWriter, r *http.Request, err error)

WriteJSONError is a helper function for writing errors in various scenarios. Taken from github.com/ory/herodot.

func WriteJSONErrorCode

func WriteJSONErrorCode(w http.ResponseWriter, r *http.Request, code int, err error)

WriteJSONErrorCode is a helper function for writing errors in various scenarios. Taken from github.com/ory/herodot.

Types

type DebugCarrier

type DebugCarrier interface {
	// Debug returns debugging information for the error, if applicable.
	Debug() string
}

DebugCarrier can be implemented by an error to support error contexts.

type DetailsCarrier

type DetailsCarrier interface {
	// Details returns details on the error, if applicable.
	Details() map[string]any
}

DetailsCarrier can be implemented by an error to support error contexts.

type IDCarrier

type IDCarrier interface {
	// ID returns application error ID on the error, if applicable.
	ID() string
}

IDCarrier can be implemented by an error to support error contexts.

type ReasonCarrier

type ReasonCarrier interface {
	// Reason returns the reason for the error, if applicable.
	Reason() string
}

ReasonCarrier can be implemented by an error to support error contexts.

type RequestIDCarrier

type RequestIDCarrier interface {
	// RequestID returns the ID of the request that caused the error, if applicable.
	RequestID() string
}

RequestIDCarrier can be implemented by an error to support error contexts.

type StackTracer

type StackTracer interface {
	StackTrace() errors.StackTrace
}

type StatusCarrier

type StatusCarrier interface {
	// Status returns the error status, if applicable.
	Status() string
}

StatusCarrier can be implemented by an error to support error contexts.

type StatusCodeCarrier

type StatusCodeCarrier interface {
	// StatusCode returns the status code of this error.
	StatusCode() int
}

StatusCodeCarrier can be implemented by an error to support setting status codes in the error itself.

Jump to

Keyboard shortcuts

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