errors

package
v2.8.1 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrPermission is the standard "Permission Denied" error
	ErrPermission = errors.New("You don't have required permission to perform this action")
	// ErrAuthorization is the standard "Unauthorized" error
	ErrAuthorization = errors.New("User is unauthorized, make sure you've logged in")
	// ErrInternal is the standard "Internal Server" error
	ErrInternal = errors.New("Internal server error, please try again later")
	// ErrInvalidParameters is the standard "Bad Request" error
	ErrInvalidParameters = errors.New("Some of the request parameters are not correct")
	// ErrUnmarshalling is the JSON deserialization error
	ErrUnmarshalling = errors.New("Failed to read JSON from the request body")
	// ErrForm is the form parsing error
	ErrForm = errors.New("Failed to parse the submitted form")
	// ErrNotFound is the standard entiry not found error
	ErrNotFound = errors.New("The requested object was not found")
	// ErrNotImplemented is intended to be used when stubbing new endpoints
	ErrNotImplemented = errors.New("Method is not implemented")
)

Functions

This section is empty.

Types

type ErrorType

type ErrorType string

ErrorType : The type of the error response

const (
	// GeneralErrorType is a generic error type
	GeneralErrorType ErrorType = "GeneralError"
	// FieldErrorType is a field validation error type
	FieldErrorType ErrorType = "FieldError"
)

type FieldError

type FieldError struct {
	GeneralError
	// Key of the validated field
	Key string `json:"key"`
}

FieldError represents a validation error

type FieldErrorResponse

type FieldErrorResponse struct {
	// Errors is a list of errors
	Errors []FieldError `json:"errors"`
}

FieldErrorResponse - Error message that contains detailed information about certain parameters being incorrect

func ValidationErrorsToFieldErrorResponse

func ValidationErrorsToFieldErrorResponse(errs ValidationErrors) (fieldErrResp FieldErrorResponse)

ValidationErrorsToFieldErrorResponse converts validation errors to the format that is served by HTTP handlers

type GeneralError

type GeneralError struct {
	// Type of the error
	Type ErrorType `json:"type"`
	// Message of the validation error
	Message string `json:"message"`
}

GeneralError represents a system error exposed to the user

type GeneralErrorResponse

type GeneralErrorResponse struct {
	// Errors is a list of errors
	Errors []GeneralError `json:"errors"`
}

GeneralErrorResponse - General error response that usually has a very generic message

type ValidationErrors

type ValidationErrors = validation.Errors

ValidationErrors contains errors organized by validated fields for now it's just an alias to the validation library we use

Jump to

Keyboard shortcuts

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