errors

package module
v0.0.0-...-efcb511 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2020 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorHandlerMiddleware

func ErrorHandlerMiddleware() gin.HandlerFunc

ErrorHandlerMiddleware :

Types

type Error

type Error struct {
	Error *ErrorResponse `json:"error,omitempty"`
}

Error represents the error object

type ErrorObject

type ErrorObject struct {
	Domain       string `json:"domain,omitempty"`
	Reason       string `json:"reason,omitempty"`
	Message      string `json:"message,omitempty"`
	ExtendedHelp string `json:"extendedHelp,omitempty"`
	SendReport   string `json:"sendReport,omitempty"`
}

ErrorObject gives extensive info to the error and other errors involved

var InternalError ErrorObject = ErrorObject{
	Reason:  "InternalServerError",
	Message: "whoops something went wrong",
}

InternalError a response for any internal error within the system

var ValidationError ErrorObject = ErrorObject{
	Reason:  "FieldValidationError",
	Message: "Your request is in a bad format",
}

ValidationError a response for validation errors

type ErrorResponse

type ErrorResponse struct {
	StatusCode int           `json:"statusCode"`
	Message    string        `json:"message"`
	Errors     []ErrorObject `json:"errors,omitempty"`
}

ErrorResponse represents the response of the error

Jump to

Keyboard shortcuts

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