errors

package
v2.1.14 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogData

func LogData(err error) log.Data

LogData returns logData for an error if there is any

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

News 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

Jump to

Keyboard shortcuts

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