errors

package
v2.203.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromBody added in v2.162.0

func FromBody(body io.Reader) error

func LogData

func LogData(err error) log.Data

LogData returns logData for an error if there is any

func NewErrorFromUnhandledStatusCode added in v2.130.0

func NewErrorFromUnhandledStatusCode(service string, statusCode int) error

func StatusCode

func StatusCode(err error) int

StatusCode is a callback function that allows you to extract a status code from an error, or returns 500 as a default

func UnwrapLogData

func UnwrapLogData(err error) log.Data

UnwrapLogData recursively unwraps logData from an error

Types

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error is a common error for HTTP APIs to return associated status code and logdata from API calls made

func New

func New(err error, statusCode int, logData map[string]interface{}) *Error

New a new Error

func (*Error) Code

func (e *Error) Code() int

Code returns the statusCode returned by Cantabular. Hopefull can be renamed to StatusCodea some point but this is how it is named elsewhere across ONS services and is more useful being consistent

func (*Error) Error

func (e *Error) Error() string

Error implements the standard Go error

func (*Error) LogData

func (e *Error) LogData() map[string]interface{}

LogData implemented the DataLogger interface and allows log data to be embedded in and retrieved from an error

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap implements Go error unwrapping

type JsonError added in v2.106.0

type JsonError struct {
	Code        string `json:"errorCode"`
	Description string `json:"description"`
}

type JsonErrors added in v2.106.0

type JsonErrors struct {
	Errors []JsonError `json:"errors"`
}

func (JsonErrors) ToNativeError added in v2.106.0

func (j JsonErrors) ToNativeError() error

Jump to

Keyboard shortcuts

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