Help us shape the future of Go! Take the 2026 Go Developer Survey

errors

package module
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: Apache-2.0 Imports: 13 Imported by: 12

Documentation

Index

Constants

View Source
const (
	SentryErrorCode    = "error_code"
	SentryOperations   = "operations"
	SentryRequestID    = "request_id"
	SentryErrorContext = "wego_error"
)

sentry keys

Variables

View Source
var (
	// ErrNotSupported the requested action/resource is not supported
	ErrNotSupported = New(NotSupported, "not supported")
	// ErrNotImplemented the requested action/resource is not implemented
	ErrNotImplemented = New(NotImplemented, "not implemented")
	// ErrNotModified the requested action/resource is not modified
	ErrNotModified = New(NotModified, "not modified")
)

Functions

func CaptureError

func CaptureError(ctx context.Context, err error)

CaptureError captures an error to sentry & set level as error

func CaptureWarning

func CaptureWarning(ctx context.Context, err error)

CaptureWarning captures an error to sentry & set level as warning

func Code

func Code(err error) int

Code return HTTP status code of the error

Types

type Error

type Error struct {
	Op   Op
	Kind Kind
	Err  error
	// contains filtered or unexported fields
}

Error custom error

func New

func New(args ...interface{}) *Error

New construct a new error, default having kind Unexpected

func WrapGORMError

func WrapGORMError(op Op, err error) *Error

WrapGORMError wraps an GORM error into our error such as adding errors.Kind

func (*Error) Error

func (e *Error) Error() string

func (*Error) WithContext added in v0.1.20

func (e *Error) WithContext(ctx context.Context) *Error

WithContext sets the context of the error. However, it does not override the existing context if it has already been set. In the cases where there is a child node, the child node's context would have already been propagated to the current context.

type FieldError

type FieldError struct {
	validator.FieldError
}

FieldError is wrapper of validator.FieldError

func (FieldError) String

func (e FieldError) String() string

type Kind

type Kind int

Kind error kind

const (
	NotModified     Kind = http.StatusNotModified
	BadRequest      Kind = http.StatusBadRequest
	Conflict        Kind = http.StatusConflict
	Forbidden       Kind = http.StatusForbidden
	NotFound        Kind = http.StatusNotFound
	Unauthorized    Kind = http.StatusUnauthorized
	Unprocessable   Kind = http.StatusUnprocessableEntity
	TooManyRequests Kind = http.StatusTooManyRequests
	Unexpected      Kind = http.StatusInternalServerError
	Retry           Kind = -1 // Retry indicate an error we need to retry the action
	NotSupported    Kind = -2 // NotSupported THe requested action/resource is not supported
	NotImplemented  Kind = -3 // NotImplemented The requested action/resource is not implemented
)

error kinds

type Op

type Op string

Op : operation

Jump to

Keyboard shortcuts

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