e

package
v0.1.18 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Author: Daniel TAN Date: 2021-09-03 12:24:12 LastEditors: Daniel TAN LastEditTime: 2021-10-04 01:33:42 FilePath: /trinity-micro/core/e/err_msg.go Description:

Index

Constants

View Source
const (
	// ErrInvalidRequest
	/**
	 * @Author: Daniel TAN
	 * @Description: when post body, query param , path param invalid, post body validation error
	 */
	ErrInvalidRequest errorCode = 400001
	// ErrInvalidRequest
	/**
	 * @Author: Daniel TAN
	 * @Description: when calling third party API respond with unsuccessful error and without err msg
	 */
	ErrHttpResponseCodeNotSuccess errorCode = 400002
	// ErrVertexAccessDeniedException
	/**
	 * @Author: Daniel TAN
	 * @Description: when calling vertex , the auth info is wrong caused the access denied
	 */
	ErrVertexAccessDeniedException errorCode = 400003
	// ErrVertexNumberFormatException
	/**
	 * @Author: Daniel TAN
	 * @Description: when calling vertex, the number field invalid
	 */
	ErrVertexNumberFormatException errorCode = 400004
	// ErrVertexInvalidAddressException
	/**
	 * @Author: Daniel TAN
	 * @Description: when calling vertex, the address info is invalid
	 */
	ErrVertexInvalidAddressException errorCode = 400005
	// ErrVertexInvalidTaxAreaIdException
	/**
	 * @Author: Daniel TAN
	 * @Description: when calling vertex, the tax area id info is invalid
	 */
	ErrVertexInvalidTaxAreaIdException errorCode = 400006
	// ErrVertexApplicationException
	/**
	 * @Author: Daniel TAN
	 * @Description: when calling vertex, the content is invalid
	 */
	ErrVertexApplicationException errorCode = 400007
	// ErrVertexInvalidCountryException
	/**
	 * @Author: Daniel TAN
	 * @Description: when calling vertex, there country provided is invalid
	 */
	ErrVertexInvalidCountryException errorCode = 400008
	// ErrVertexUnknownException
	/**
	 * @Author: Daniel TAN
	 * @Description: when calling vertex, there has un-caught error
	 */
	ErrVertexUnknownException errorCode = 400009
	//ErrRecordNotFound
	/**
	 * @Author: Daniel TAN
	 * @Description: when http query, http body has some resource not found , return this error
	 * @Description: for example, post {"store":"112201"}, the store not exist
	 */
	ErrRecordNotFound errorCode = 400010
	//ErrAdvisoryLock
	/**
	 * @Author: Daniel TAN
	 * @Description: when trying to lock with advisory error
	 */
	ErrAdvisoryLock errorCode = 400011
	//ErrAdvisoryLock
	/**
	 * @Author: Daniel TAN
	 * @Description:when trying to unlock with advisory error
	 */
	ErrAdvisoryUnlock errorCode = 400012
	//ErrDIParam
	/**
	 * @Author: Daniel TAN
	 * @Description:error when trying to di the param
	 */
	ErrDIParam errorCode = 400013
	//ErrDecodeRequestBody
	/**
	 * @Author: Daniel TAN
	 * @Description:error when decode the request body
	 */
	ErrDecodeRequestBody errorCode = 400014
	//ErrDBUpdateZeroLine
	/**
	 * @Author: Daniel TAN
	 * @Description: 0 rows affected when update the record
	 */
	ErrDBUpdateZeroLine errorCode = 400015
)

400 error

View Source
const (
	// ErrInternalServer
	/**
	 * @Author: Daniel TAN
	 * @Description: the default error, which is unexpected from the developers
	 */
	ErrInternalServer errorCode = 500001
	// ErrReadResponseBody
	/**
	 * @Author: Daniel TAN
	 * @Description: when read third party response, we met unexpected error while reading the response body
	 */
	ErrReadResponseBody errorCode = 500002
	// ErrDecodeResponseBody
	/**
	 * @Author: Daniel TAN
	 * @Description: when read third party response, we met unexpected error while decode the response body
	 */
	ErrDecodeResponseBody errorCode = 500003
	// ErrExecuteSQL
	/**
	 * @Author: Daniel TAN
	 * @Description: when execute the sql, met unexpected error
	 */
	ErrExecuteSQL errorCode = 500004
	// ErrReadRequestBody
	/**
	 * @Author: Daniel TAN
	 * @Description: when read request body, met unexpected error
	 */
	ErrReadRequestBody errorCode = 500005

	ErrPanic errorCode = 500006
)

500 error

View Source
const (
	// Info info level
	Info LogLevel = "Info"
	// Error err level
	Error = "Error"
	// Warn warn level
	Warn = "Warn"
)
View Source
const (
	// ErrResourceNotFound
	/**
	 * @Author: Daniel TAN
	 * @Description: only when get /{id}, the id not found, we response this error
	 */
	ErrResourceNotFound errorCode = 404001
)

404 error

View Source
const (
	ErrUnauthorized = 401001
)

Variables

This section is empty.

Functions

func Is

func Is(err error, targetErrorCode errorCode) bool

func Logging

func Logging(logger logrus.FieldLogger, err error)

Logging log func *

  • @Author: Daniel TAN
  • @Description:
  • @Date: 2020-11-24 09:51:48
  • @LastEditors: Daniel TAN
  • @param {*logrus.Entry} logger
  • @param {error} err
  • @return {*}

func NewAPIError

func NewAPIError(err error) *httpError

create a http error from the eror

Types

type LogLevel

type LogLevel string

LogLevel log level

type WrapError

type WrapError interface {
	LogLevel() LogLevel
	Code() errorCode
	Error() string
	Message() string
}

WrapError wrap err

func NewError

func NewError(loglevel LogLevel, code errorCode, msg string, rootCauses ...error) WrapError

NewError new error *

  • @Author: Daniel TAN
  • @Description:
  • @Date: 2020-11-23 19:25:16
  • @LastEditors: Daniel TAN
  • @param {LogLevel} loglevel
  • @param {string} msg
  • @param {error} err
  • @return {*}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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