errors

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const ErrorMessagesFilePath = "/Users/hq/go/src/ecommerce/src/errors/error_messages.json"

ErrorMessagesFilePath is path of error_messages.json file.

View Source
const (
	ModuleCommon = 00
)

Variables

View Source
var (
	InvalidRequestError   = fmtErrorCode(http.StatusBadRequest, ModuleCommon, 1) // 400001
	PermissionAccessError = fmtErrorCode(http.StatusForbidden, ModuleCommon, 1)
	ErrorRecordNotFound   = fmtErrorCode(http.StatusNotFound, ModuleCommon, 1)            // 404001
	InternalServerError   = fmtErrorCode(http.StatusInternalServerError, ModuleCommon, 1) // 500001
	ErrNoResponse         = fmtErrorCode(http.StatusInternalServerError, ModuleCommon, 3) // 500003

)

common should be defined in common package used by all services.

Functions

func GetErrorMessage

func GetErrorMessage(errCode ErrorCode, args ...interface{}) string

GetErrorMessage gets error message from errorMessageMap.

func InitErrorMessagesResource

func InitErrorMessagesResource() error

InitErrorMessagesResource loads error messages resource.

func New

func New(errCode ErrorCode, args ...interface{}) error

Types

type AppError

type AppError struct {
	Meta      ErrorMeta `json:"meta"`
	ErrorCode ErrorCode `json:"-"`
}

func (AppError) Error

func (appErr AppError) Error() string

type ErrorCode

type ErrorCode struct {
	// contains filtered or unexported fields
}

func (ErrorCode) Code

func (errCode ErrorCode) Code() int

func (ErrorCode) DetailCode

func (errCode ErrorCode) DetailCode() int

func (ErrorCode) Module

func (errCode ErrorCode) Module() int

func (ErrorCode) Status

func (errCode ErrorCode) Status() int

type ErrorMeta

type ErrorMeta struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

Jump to

Keyboard shortcuts

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