orberrors

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2025 License: Apache-2.0 Imports: 5 Imported by: 29

Documentation

Overview

Package orberrors provides an error that must be transported on client<->server operations.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBadRequest          = newHTTP(http.StatusBadRequest)     // 400
	ErrUnauthorized        = newHTTP(http.StatusUnauthorized)   // 401
	ErrNotFound            = newHTTP(http.StatusNotFound)       // 404
	ErrRequestTimeout      = newHTTP(http.StatusRequestTimeout) // 408
	ErrCanceled            = newHTTP(499)
	ErrUnimplemented       = newHTTP(http.StatusInternalServerError) // 500
	ErrNotImplemented      = newHTTP(http.StatusNotImplemented)      // 501
	ErrUnavailable         = newHTTP(http.StatusServiceUnavailable)  // 503
	ErrInternalServerError = newHTTP(http.StatusInternalServerError) // 500
)

A list of default errors.

Functions

This section is empty.

Types

type Error

type Error struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Wrapped error  `json:"wrapped"`
}

Error is the orb error, it contain's a "Code" additional to the Message.

func As

func As(err error) (*Error, bool)

As tries to convert an `error` into an `*orberrors.Error`.

func From

func From(err error) *Error

From wraps an error into orberrors.Error.

func HTTP

func HTTP(code int) *Error

HTTP returns an orb error with the given status code and a static message.

func New

func New(code int, message string) *Error

New creates a new orb error with the given parameters.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Is

func (e *Error) Is(err error) bool

Is returns if the given error is an (orb)Error.

func (*Error) Toerror

func (e *Error) Toerror() error

Toerror converts the "Error" to "error", same as doing <variableWithTypeError>.(error).

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns the wrapped error.

func (*Error) Wrap

func (e *Error) Wrap(err error) *Error

Wrap creates a new error and wraps another error.

func (*Error) WrapF added in v0.3.0

func (e *Error) WrapF(message string, args ...any) *Error

WrapF creates a new error and wraps another error with a new message and args.

func (*Error) WrapNew added in v0.3.0

func (e *Error) WrapNew(message string) *Error

WrapNew creates a new error and wraps another error with a new message.

Jump to

Keyboard shortcuts

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