errors

package
v0.0.0-...-367ce81 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnauthorized          apiErrorFn = DefineError(70401, "Sign-In Required", 401)       // client is not authenticated
	ErrInsufficientPrivilege apiErrorFn = DefineError(70403, "Insufficient Privilege", 403) // client lacks privilege
	ErrDontBeSilly           apiErrorFn = DefineError(70470, "Don't Be Silly", 403)         // client is trying to do something stupid

	ErrUnknownEmote          apiErrorFn = DefineError(70440, "Unknown Emote", 404)           // can't find emote object
	ErrUnknownEmoteSet       apiErrorFn = DefineError(70441, "Unknown Emote Set", 404)       // can't find emote set object
	ErrUnknownUser           apiErrorFn = DefineError(70442, "Unknown User", 404)            // can't find user object
	ErrUnknownUserConnection apiErrorFn = DefineError(70442, "Unknown User Connection", 404) // can't find user connection object
	ErrUnknownRole           apiErrorFn = DefineError(70443, "Unknown Role", 404)            // can't find role object
	ErrUnknownReport         apiErrorFn = DefineError(70444, "Unknown Report", 404)          // can't find report object
	ErrUnknownMessage        apiErrorFn = DefineError(70445, "Unknown Message", 404)         // can't find message object
	ErrUnknownBan            apiErrorFn = DefineError(70446, "Unknown Ban", 404)             // can't find ban object
	ErrUnknownRoute          apiErrorFn = DefineError(70447, "Unknown Route", 404)           // the requested api endpoint doesn't exist
	ErrUnknownSession        apiErrorFn = DefineError(70448, "Unknown Session", 404)         // can't find requested session (used by event api)
	ErrNoItems               apiErrorFn = DefineError(70449, "No Items Found", 404)          // search returned nothing

	ErrInvalidRequest     apiErrorFn = DefineError(70410, "Invalid Request", 400)
	ErrBadObjectID        apiErrorFn = DefineError(70411, "Bad Object ID", 400)
	ErrBadInt             apiErrorFn = DefineError(70412, "Bad Int", 400)
	ErrValidationRejected apiErrorFn = DefineError(70413, "Validation Rejected", 400)
	ErrInternalField      apiErrorFn = DefineError(70414, "Internal Field", 400)
	ErrEmptyField         apiErrorFn = DefineError(70415, "Empty Field", 400)

	ErrEmoteNotEnabled                apiErrorFn = DefineError(704610, "Emote Not Enabled", 400)             // client wants to disable an emote which was not enabled to begin with
	ErrEmoteAlreadyEnabled            apiErrorFn = DefineError(704611, "Emote Already Enabled", 400)         // client wants to enable an emote which is already added
	ErrEmoteNameConflict              apiErrorFn = DefineError(704612, "Emote Name Conflict", 400)           // client wants to enable an emote but its name conflict with another
	ErrEmoteNameInvalid               apiErrorFn = DefineError(704613, "Bad Emote Name", 400)                // client sent an emote name that did not pass validation
	ErrEmoteVersionNameInvalid        apiErrorFn = DefineError(704614, "Bad Emote Version Name", 400)        // client sent an emote version name that did not pass validation
	ErrEmoteVersionDescriptionInvalid apiErrorFn = DefineError(704615, "Bad Emote Version Description", 400) // client sent an emote version description that did not pass validation
	ErrNoSpaceAvailable               apiErrorFn = DefineError(704620, "No Space Available", 403)            // the target object is full
	ErrMissingRequiredField           apiErrorFn = DefineError(704680, "Missing Field", 400)

	ErrInternalServerError        apiErrorFn = DefineError(70500, "Internal Server Error", 500)
	ErrMissingInternalDependency  apiErrorFn = DefineError(70510, "Missing Internal Dependency", 503)
	ErrInternalIncompleteMutation apiErrorFn = DefineError(70560, "Incomplete Mutation (internal)", 500)
	ErrMutateTaintedObject        apiErrorFn = DefineError(70570, "Tainted Object Mutation", 500) // mutation on a tainted (already mutated) Builder
)

Functions

func Compare

func Compare(er1 error, er2 APIError) bool

func DefineError

func DefineError(code int, s string, httpStatus int) func() APIError

Types

type APIError

type APIError interface {
	Error() string
	Message() string
	Code() int
	SetDetail(str string, a ...any) *apiError
	SetFields(d Fields) *apiError
	GetFields() Fields
	ExpectedHTTPStatus() int
	WithHTTPStatus(s int) *apiError
}

func From

func From(e error) APIError

type Fields

type Fields map[string]interface{}

Jump to

Keyboard shortcuts

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