errors

package
v0.0.0-...-7c8ce1f Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrDuplicateAccount

func ErrDuplicateAccount(w http.ResponseWriter, statusCode int)

func ErrFailedConversion

func ErrFailedConversion(w http.ResponseWriter, statusCode int)

func ErrFailedMarshalBinaryLengthPrefixed

func ErrFailedMarshalBinaryLengthPrefixed(w http.ResponseWriter, statusCode int)

func ErrFailedUnmarshalJSON

func ErrFailedUnmarshalJSON(w http.ResponseWriter, statusCode int)

func ErrInternalServer

func ErrInternalServer(w http.ResponseWriter, statusCode int)

func ErrInvalidFormat

func ErrInvalidFormat(w http.ResponseWriter, statusCode int)

func ErrInvalidMessageType

func ErrInvalidMessageType(w http.ResponseWriter, statusCode int)

func ErrInvalidParam

func ErrInvalidParam(w http.ResponseWriter, statusCode int, msg string)

func ErrNotAllowed

func ErrNotAllowed(w http.ResponseWriter, statusCode int)

func ErrNotExist

func ErrNotExist(w http.ResponseWriter, statusCode int)

func ErrOverMaxLimit

func ErrOverMaxLimit(w http.ResponseWriter, statusCode int)

func ErrRequiredParam

func ErrRequiredParam(w http.ResponseWriter, statusCode int, msg string)

func PrintException

func PrintException(w http.ResponseWriter, statusCode int, err WrapError)

PrintException prints out the exception result

Types

type ErrorCode

type ErrorCode uint32

ErrorCode represents custom error code used in this application.

const (
	InternalServer ErrorCode = 101

	DuplicateAccount   ErrorCode = 201
	InvalidFormat      ErrorCode = 202
	NotExist           ErrorCode = 203
	NotAllowed         ErrorCode = 204
	FailedConversion   ErrorCode = 205
	InvalidMessageType ErrorCode = 207

	OverMaxLimit                      ErrorCode = 301
	FailedUnmarshalJSON               ErrorCode = 302
	FailedMarshalBinaryLengthPrefixed ErrorCode = 303

	RequiredParam ErrorCode = 601
	InvalidParam  ErrorCode = 602
)

type ErrorMsg

type ErrorMsg string

ErrorMsg represents error message that will be returned to client for any error.

func ErrorCodeToErrorMsg

func ErrorCodeToErrorMsg(code ErrorCode) ErrorMsg

ErrorCodeToErrorMsg returns error message from error code

func ErrorCodeToErrorMsgs

func ErrorCodeToErrorMsgs(code ErrorCode, msg string) ErrorMsg

ErrorCodeToErrorMsgs returns error message concatenating with custom message from error code

type WrapError

type WrapError struct {
	ErrorCode ErrorCode `json:"error_code"`
	ErrorMsg  ErrorMsg  `json:"error_msg"`
}

WrapError wraps both error code and error message.

Jump to

Keyboard shortcuts

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