problems

package
v0.0.0-...-4515e61 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2019 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultType = "about:blank"

DefaultType implements the default type content described in RFC 7807

Variables

This section is empty.

Functions

func WithMessage

func WithMessage(err error, msg string) error

WithMessage is an alias to github.com/pkg/errors WithMessage function. If Problem pointer passed as error, it sets the error, stacktrace and message of Problem.

func WithStack

func WithStack(err error) error

WithStack is an alias to github.com/pkg/errors WithStack function. If Problem pointer passed as error, it sets the error of Problem.

func Wrap

func Wrap(err error, msg string) error

Wrap is an alias to github.com/pkg/errors Wrap function. If Problem pointer passed as error, it sets the error and a new message of Problem.

Types

type Problem

type Problem struct {
	Title    string `json:"title,omitempty"`
	Detail   string `json:"detail,omitempty"`
	Type     string `json:"type"`
	Instance string `json:"instance,omitempty"`
	Status   int    `json:"status,omitempty"`
	// contains filtered or unexported fields
}

Problem implements the RFC 7807 "problem"/error standard Additional error field can be defined in custom struct implementing the Problem struct

func New

func New(title, detail string, status int) *Problem

New creates a new Problem with all object details described in RFC 7807

func (Problem) Cause

func (p Problem) Cause() error

Cause returns the outermost error of Problem

func (Problem) Error

func (p Problem) Error() string

Error returns the error of the problem

func (Problem) Format

func (p Problem) Format(s fmt.State, verb rune)

Format displays the contained error in a specific format

func (Problem) SetDetail

func (p Problem) SetDetail(detail string) *Problem

SetDetail sets the detail field of the problem, specified in RFC 7807

func (Problem) SetInstance

func (p Problem) SetInstance(instance string) *Problem

SetInstance sets the instance field of the problem, specified in RFC 7807

func (Problem) SetStatus

func (p Problem) SetStatus(status int) *Problem

SetStatus sets the status field of the problem, specified in RFC 7807

func (Problem) SetTitle

func (p Problem) SetTitle(title string) *Problem

SetTitle sets the title field of the problem, specified in RFC 7807

func (Problem) SetType

func (p Problem) SetType(t string) *Problem

SetType sets the detail field of the problem, specified in RFC 7807

Jump to

Keyboard shortcuts

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