apperror

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetErrorCode

func GetErrorCode(err error) int

Extract error code int apperror

Types

type ErrorType

type ErrorType string

ErrorType must not modified

const (
	ERR500                            ErrorType = "ER500 %s"                                      // custom err500 message
	ERR400                            ErrorType = "ER400 %s"                                      // custom err500 messag
	FailUnmarshalResponseBodyError    ErrorType = "ER400 fail to unmarshal response body"         // used by controller
	ObjectNotFound                    ErrorType = "ER404 object %s is not found"                  // used by injected repo in interactor
	UnrecognizedEnum                  ErrorType = "ER500 %s is not recognized %s enum"            // used by enum
	DatabaseNotFoundInContextError    ErrorType = "ER500 database is not found in context"        // used by repoimpl
	JWTSecretKeyMustNotEmpty          ErrorType = "ER500 JWT secret key must not empty"           // used by repoimpl
	CannotGenerateID                  ErrorType = "ER500 cannot generate error"                   // used by repoimpl
	DateMustNotEmpty                  ErrorType = "ER400 date must not empty"                     // used by repoimpl
	AuditIDMustNotEmpty               ErrorType = "ER400 audit id must not empty"                 //
	RoomIDMustNotEmpty                ErrorType = "ER400 room id must not empty"                  //
	ItemIDMustNotEmpty                ErrorType = "ER400 item id must not empty"                  //
	ItemIsAlreadyScannedInThisSession ErrorType = "ER400 item is already scanned in this session" //
)

func (ErrorType) Code

func (u ErrorType) Code() string

Code return the only code

func (ErrorType) CodeInt

func (u ErrorType) CodeInt() int

Code return the only code int type

func (ErrorType) Error

func (u ErrorType) Error() string

Error return the only message

func (ErrorType) String

func (u ErrorType) String() string

String return the error as it is

func (ErrorType) Var

func (u ErrorType) Var(params ...interface{}) ErrorType

Var add generic variable value to the error message for example you have UserNotFoundError ErrorType = "ER1092 User with name %s is not found" Then you can insert the name UserNotFoundError.Var("mirza") --> "User with name mirza is not found"

type ErrorWithCode

type ErrorWithCode interface {
	error
	Code() string
	CodeInt() int
}

Jump to

Keyboard shortcuts

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