glitch

package
v0.0.0-...-ca56d95 Latest Latest
Warning

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

Go to latest
Published: May 19, 2021 License: Apache-2.0 Imports: 1 Imported by: 13

Documentation

Index

Constants

View Source
const UnknownCode = "UNKNOWN"

UnknownCode is used as the code when a real code could not be found

Variables

This section is empty.

Functions

This section is empty.

Types

type DataError

type DataError interface {
	// Error satisfies the error interface
	Error() string
	// Inner returns the originating error
	Inner() error
	// Code returns a specific error code, this is meant to be a machine friendly string
	Code() string
	// Msg returns the originating message
	Msg() string
	// Wrap will set err as the cause of the error and returns itself
	Wrap(err DataError) DataError
	// GetCause will return the cause of this error
	GetCause() DataError
	// IsTransient will return if the error is considered transient
	IsTransient() bool
	// GetFields returns the extra fields for giving better error descriptions
	GetFields() map[string]interface{}
	// GetField returns the data of a field from the fields member of the DataError if one exists
	GetField(name string) interface{}
	// AddFields will add fields to the given DataErrors fields
	AddFields(map[string]interface{})
	// AddField will add the key and value pair to the data errors fields
	AddField(key string, value interface{})
	// String implements the string interface for %s in fmt calls
	String() string
}

DataError is a class of error that provides access to an error code as well as the originating error

func FromHTTPProblem

func FromHTTPProblem(inner error, msg string) DataError

FromHTTPProblem will create a DataError from an HTTPProblem

func NewDataError

func NewDataError(inner error, code string, msg string) DataError

NewDataError will create a DataError from the information provided

func NewTransientDataError

func NewTransientDataError(inner error, code string, msg string) DataError

NewTransientDataError will create a DataError from the information provided and set the isTransient flag to true

type HTTPProblem

type HTTPProblem struct {
	Type        string `json:"type,omitempty"`
	Title       string `json:"title,omitempty"`
	Status      int    `json:"status,omitempty"`
	Detail      string `json:"detail,omitempty"`
	Instance    string `json:"instance,omitempty"`
	Code        string `json:"code,omitempty"`
	IsTransient bool   `json:"is_transient"`
}

HTTPProblem should be used as the response in case of an error during an HTTP request. It implements the https://datatracker.ietf.org/doc/rfc7807 spec with these additional fields:

code: meant to be machine readable and give clients enough information to handle the error appropriately
is_transient: meant to inform clients that the problem is considered transient and could be retried

swagger:model HTTPProblem

func (HTTPProblem) Error

func (h HTTPProblem) Error() string

type HTTPProblemMetadata

type HTTPProblemMetadata struct {
	HTTPProblem
	Metadata interface{} `json:"metadata"`
}

func (HTTPProblemMetadata) Error

func (h HTTPProblemMetadata) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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