dictionary

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package dictionary is for our standardized error responses

Index

Constants

View Source
const (
	ErrorBadErrorCode           = 1
	ErrorConfigValidation       = 2
	ErrorDatabaseOpen           = 3
	ErrorDatabasePing           = 4
	ErrorDatabaseUnknownDriver  = 5
	ErrorDecryptEnv             = 6
	ErrorInvalidEnv             = 7
	ErrorLoadingCache           = 8
	ErrorLoadingConfig          = 9
	ErrorMethodNotAllowed       = 10
	ErrorMissingEnv             = 11
	ErrorReadingConfig          = 12
	ErrorRequestNotFound        = 13
	ErrorViper                  = 14
	ErrorLoadingService         = 15
	ErrorAuthenticationError    = 16
	ErrorAuthenticationScheme   = 17
	ErrorAuthenticationNotAdmin = 18
	ErrorAuthenticationCallback = 19
)

ErrorCode constants for the different error responses Leave the start and last constants in place

Variables

This section is empty.

Functions

func GetInternalMessage

func GetInternalMessage(code ErrorCode) string

GetInternalMessage will return the internal message based on the given error code

func GetPublicMessage

func GetPublicMessage(code ErrorCode) string

GetPublicMessage will return the public message based on the given error code

func GetStatusCode

func GetStatusCode(code ErrorCode) int

GetStatusCode will return the http status code on the given error code

Types

type ErrorCode

type ErrorCode uint16

ErrorCode is a unique code for a specific error message

func (ErrorCode) IsValid

func (e ErrorCode) IsValid() bool

IsValid tests if the error code is valid or not

type ErrorMessage

type ErrorMessage struct {
	Code            ErrorCode `json:"code"`
	InternalMessage string    `json:"internal_message"`
	PublicMessage   string    `json:"public_message"`
	StatusCode      int       `json:"status_code"`
}

ErrorMessage is used for standardizing the messages/codes for errors

func GetError

func GetError(code ErrorCode, internalMessageReplacements ...interface{}) ErrorMessage

GetError will return the error based on the given error code Set replacements for Sprintf() on the internal message if needed

Jump to

Keyboard shortcuts

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