errors

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Status  int    `json:"status"`
	Title   string `json:"title"`
	Details string `json:"details"`
}

APIError fulfills the error and APIErrors interfaces. It contains a single error.

func AppAlreadyKnown

func AppAlreadyKnown(app string) APIError

AppAlreadyKnown constructs an API error for when we have a conflict with an existing app

func AppIsNotKnown

func AppIsNotKnown(app string) APIError

AppIsNotKnown constructs an API error for when the desired app does not exist

func BadRequest

func BadRequest(err error, details ...string) APIError

BadRequest constructs an API error for general issues with a request, from a lower-level error

func InternalError

func InternalError(err error, details ...string) APIError

InternalError constructs an API error for server internal issues, from a lower-level error

func NewAPIError

func NewAPIError(title string, details string, status int) APIError

NewAPIError constructs an APIerror from basics

func NewBadRequest

func NewBadRequest(msg string, details ...string) APIError

NewBadRequest constructs an API error for general issues with a request, from a message

func NewInternalError

func NewInternalError(msg string, details ...string) APIError

NewInternalError constructs an API error for server internal issues, from a message

func NewNotFoundError

func NewNotFoundError(msg string, details ...string) APIError

NewNotFoundError constructs a general API error for when something desired does not exist

func OrgAlreadyKnown

func OrgAlreadyKnown(org string) APIError

OrgAlreadyKnown constructs an API error for when we have a conflict with an existing org

func OrgIsNotKnown

func OrgIsNotKnown(org string) APIError

OrgIsNotKnown constructs an API error for when the desired org does not exist

func ServiceAlreadyBound

func ServiceAlreadyBound(service string) APIError

ServiceAlreadyBound constructs an API error for when the service to bind is already bound to the app

func ServiceAlreadyKnown

func ServiceAlreadyKnown(service string) APIError

ServiceAlreadyKnown constructs an API error for when we have a conflict with an existing service instance

func ServiceIsNotBound

func ServiceIsNotBound(service string) APIError

ServiceIsNotBound constructs an API error for when the service to unbind is actually not bound to the app

func ServiceIsNotKnown

func ServiceIsNotKnown(service string) APIError

ServiceIsNotKnown constructs an API error for when the desired service instance does not exist

func UserNotFound

func UserNotFound() APIError

UserNotFound constructs an API error for when the user name is not found in the header

func (APIError) Error

func (a APIError) Error() string

Error satisfies the error interface

func (APIError) Errors

func (a APIError) Errors() []APIError

Errors satisfies the APIErrors interface

func (APIError) FirstStatus

func (a APIError) FirstStatus() int

FirstStatus (APIErrors interface) returns the stored error's status

type APIErrors

type APIErrors interface {
	Errors() []APIError
	FirstStatus() int
}

APIErrors is the interface used by all handlers to return one or more errors

type ErrorResponse

type ErrorResponse struct {
	Errors []APIError `json:"errors"`
}

ErrorResponse is the response's JSON, that is send in case of an error

type MultiError

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

MultiError fulfills the APIErrors interface. It contains multiple errors.

func NewMultiError

func NewMultiError(errs []APIError) MultiError

NewMultiError constructs an APIerror from basics

func (MultiError) Error

func (m MultiError) Error() string

Error satisfies the error interface

func (MultiError) Errors

func (m MultiError) Errors() []APIError

Errors satisfies the APIErrors interface

func (MultiError) FirstStatus

func (m MultiError) FirstStatus() int

FirstStatus (APIErrors interface) returns the status of the first error stored

Jump to

Keyboard shortcuts

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