errors

package
v2.2.4 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CannotBeBlank indicates a field that was submitted blank, but is required
	CannotBeBlank = "cannot-be-blank"
	// Canceled indicates the operation was canceled (typically by the caller).
	Canceled = "canceled"
	// ValidationError indicates that a validation rule such as min / max value was violated
	ValidationError = "validation-error"
	// MethodNotAllowed indicates that the attempted VERB is not implemented for that endpoint
	MethodNotAllowed = "method-not-allowed"
	// MalformedURL indicates that the URL was not parsable as input
	MalformedURL = "malformed-url"
	// InvalidRoute indicates that the route does not exist
	InvalidRoute = "invalid-route"
	// AuthenticationFailed indicates that authentication did not complete successfully
	AuthenticationFailed = "authentication-failed"
	// NotAuthorized indicates that the currently authenticated user is not
	// permitted to perform an action
	NotAuthorized = "not-authorized"
	// SystemError indicates that a systemic issue has occurred with the request
	SystemError = "system-error"
	// NotFound indicates that the requested resource was not found
	NotFound = "not-found"
	// AlreadyExists indicates that the requested resource already exist
	AlreadyExists = "already-exists"
)

Variables

This section is empty.

Functions

func NewNotAuthenticatedError

func NewNotAuthenticatedError() errors.TracerError

NewNotAuthenticatedError instantiates a NotAuthenticatedError with a stack trace

func NewNotFoundError

func NewNotFoundError() errors.TracerError

NewNotFoundError instantiates a NotFoundError with a stack trace

func TranslateError

func TranslateError(container RestErrorContainer, err error)

TranslateError from an ErrorMessage to a RestError and set it on a ErrorContainer

Types

type FieldError

type FieldError struct {
	Code    string `json:"code"`
	Message string `json:"message"`
	Field   string `json:"field"`
}

FieldError represents a validation error related to a specific input field

func NewFieldError

func NewFieldError(code, message, field string) *FieldError

NewFieldError instantiates a FieldError

func (*FieldError) Error

func (err *FieldError) Error() string

type NotAuthenticatedError

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

NotAuthenticatedError is returned for a failed login attempt

func (*NotAuthenticatedError) Error

func (err *NotAuthenticatedError) Error() string

func (*NotAuthenticatedError) Trace

func (err *NotAuthenticatedError) Trace() []string

Trace returns the stack trace for the error

type NotFoundError

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

NotFoundError is returned when the requested resource isn't found

func (*NotFoundError) Error

func (err *NotFoundError) Error() string

func (*NotFoundError) Trace

func (err *NotFoundError) Trace() []string

Trace returns the stack trace for the error

type RestError

type RestError struct {
	Code    string        `json:"code"`
	Message string        `json:"message"`
	Details []interface{} `json:"details"`
}

RestError represents the standard error returned by the API Gateway

func NewRestError

func NewRestError(code string, message string, details []interface{}) *RestError

NewRestError instantiates a RestError

func (*RestError) AddDetail

func (restError *RestError) AddDetail(errorDetail interface{})

AddDetail adds a detail such as a FieldError to an Error response

func (*RestError) Error

func (restError *RestError) Error() string

type RestErrorContainer

type RestErrorContainer interface {
	// SetError to the passed error and status code
	SetError(*RestError, int)
}

RestErrorContainer holds a RestError

Jump to

Keyboard shortcuts

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