glitch

package
v0.0.0-...-26ff8f2 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2022 License: Apache-2.0 Imports: 1 Imported by: 11

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
	// 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
}

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

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"`
}

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 an addition code field which is meant to be machine readable and give clients enough information to handle the error appropriately.

func (HTTPProblem) Error

func (h HTTPProblem) Error() string

Jump to

Keyboard shortcuts

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