trerror

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SUCCESS       = 200 //成功
	ERROR         = 500 //失败
	InvalidParams = 400 //参数错误
)

Variables

View Source
var (
	TR_SUCCESS               = &TrError{200, "成功"}
	TR_BAD_REQUEST           = &TrError{400, "无效的请求"}
	TR_ERROR                 = &TrError{500, "服务器错误"}
	TR_SYSTEM_ERROR          = &TrError{5001, "系统错误"}
	TR_SYSTEM_BUSY           = &TrError{5002, "系统繁忙"}
	TR_TIMEOUT               = &TrError{5003, "请求超时"}
	TR_INVALID_TOKEN         = &TrError{4001, "无效token"}
	TR_FILE_TOO_LARGE        = &TrError{4002, "文件过大"}
	TR_DUPLICATE_PRIMARY_KEY = &TrError{4003, "重复主键"}
	TR_LOGIN_ERROR           = &TrError{4004, "登录错误"}
	TR_NOT_LOGIN             = &TrError{4005, "用户未登录"}
	TR_USER_NOT_EXIST        = &TrError{4006, "用户不存在"}
	TR_DISABLED_USER         = &TrError{4007, "用户已被禁用"}
	TR_WRONG_PASSWORD        = &TrError{4008, "密码错误"}
	TR_NO_PERMISSION         = &TrError{4019, "无权限"}
	TR_ILLEGAL_OPERATION     = &TrError{4010, "非法操作"}
	TR_RECORD_NOT_FOUND      = &TrError{4011, "记录不存在"}
	TR_EMAIL_REGISTERED      = &TrError{4012, "邮箱已被注册"}
	TR_LOGIN_UNSUPPORT       = &TrError{4013, "暂不支持此方式登录"}

	// ugc校验错误
	ContentIllegal = &TrError{10201, "文字包含违规信息"}
	ImageIllegal   = &TrError{10202, "图片包含违规信息"}
	VideoIllegal   = &TrError{10203, "视频包含违规信息"}
	// 数据库错误
	DBNotFoundError = &TrError{Code: 80001, Message: "data not found"}

	TR_ACCESS_TOO_FREQUENTLY = &TrError{99999, "访问太频繁"}
)

Functions

This section is empty.

Types

type TrError

type TrError struct {
	Code    int32
	Message string
}

func Aborted

func Aborted(reason string, args ...interface{}) *TrError

Aborted return abort Error

func AlreadyExists

func AlreadyExists(reason string, args ...interface{}) *TrError

AlreadyExists returns resource already exists Error

func Canceled

func Canceled(reason string, args ...interface{}) *TrError

Canceled returns Error for canceled

func ConfigurationError

func ConfigurationError(reason string, args ...interface{}) *TrError

ConfigurationError returns configuration Error

func CustomAbortedError

func CustomAbortedError(code uint32, msg, reason string, args ...interface{}) *TrError

CustomAbortedError return abort Error

func CustomAlreadyExistsError

func CustomAlreadyExistsError(code uint32, msg, reason string, args ...interface{}) *TrError

CustomAlreadyExistsError returns resource already exists Error

func CustomCanceledError

func CustomCanceledError(code uint32, msg, reason string, args ...interface{}) *TrError

CustomCanceledError returns Error for canceled

func CustomConfigurationError

func CustomConfigurationError(code uint32, msg, reason string, args ...interface{}) *TrError

CustomConfigurationError returns configuration Error

func CustomDBError

func CustomDBError(code uint32, msg, reason string, args ...interface{}) *TrError

CustomDBError returns database Error

func CustomDeadlineExceededError

func CustomDeadlineExceededError(code uint32, msg, reason string, args ...interface{}) *TrError

CustomDeadlineExceededError returns deadline exceeded Error

func CustomError

func CustomError(code uint32, internalCode uint32, message, reason string, args ...interface{}) *TrError

CustomError returns custom Error

func CustomInternalError

func CustomInternalError(code uint32, msg, reason string, args ...interface{}) *TrError

CustomInternalError return inner server Error

func CustomInvalidArgumentError

func CustomInvalidArgumentError(code uint32, msg, reason string, args ...interface{}) *TrError

CustomInvalidArgumentError returns invalid argument Error

func CustomNotFoundError

func CustomNotFoundError(code uint32, msg, reason string, args ...interface{}) *TrError

CustomNotFoundError returns resource not found Error

func CustomPermissionDeniedError

func CustomPermissionDeniedError(code uint32, msg, reason string, args ...interface{}) *TrError

CustomPermissionDeniedError returns permission denied Error

func CustomResourceExhaustedError

func CustomResourceExhaustedError(code uint32, msg, reason string, args ...interface{}) *TrError

CustomResourceExhaustedError returns resource exhaust Error

func CustomUnauthenticatedError

func CustomUnauthenticatedError(code uint32, msg, reason string, args ...interface{}) *TrError

CustomUnauthenticatedError returns unauthenticated Error

func CustomUnavailableError

func CustomUnavailableError(code uint32, msg, reason string, args ...interface{}) *TrError

CustomUnavailableError return service unavailable Error

func CustomUnimplementedError

func CustomUnimplementedError(code uint32, msg, reason string, args ...interface{}) *TrError

CustomUnimplementedError return unimplemented Error

func CustomUnknownError

func CustomUnknownError(code uint32, msg, reason string, args ...interface{}) *TrError

CustomUnknownError returns unknown Error

func DBError

func DBError(reason string, args ...interface{}) *TrError

DBError returns database Error

func DeadlineExceeded

func DeadlineExceeded(reason string, args ...interface{}) *TrError

DeadlineExceeded returns deadline exceeded Error

func DefaultTrError

func DefaultTrError(msg string) *TrError

func Internal

func Internal(reason string, args ...interface{}) *TrError

Internal return inner server Error

func InvalidArgument

func InvalidArgument(reason string, args ...interface{}) *TrError

InvalidArgument returns invalid argument Error

func New

func New(code uint32, message string) *TrError

New Error with message and reason func New(code uint32, message, reason string, internalCode uint32) *TrError {

func NewErrorWithF

func NewErrorWithF(code uint32, internalCode uint32, message, reason string, args ...interface{}) *TrError

NewErrorWithF Error with reason fmt

func NewF

func NewF(code uint32, message, reason string, args ...interface{}) *TrError

NewF Error with reason fmt

func NewTrError

func NewTrError(code int32, msg string) *TrError

func NotFound

func NotFound(reason string, args ...interface{}) *TrError

NotFound returns resource not found Error

func PermissionDenied

func PermissionDenied(reason string, args ...interface{}) *TrError

PermissionDenied returns permission denied Error

func ResourceExhausted

func ResourceExhausted(reason string, args ...interface{}) *TrError

ResourceExhausted returns resource exhaust Error

func Unauthenticated

func Unauthenticated(reason string, args ...interface{}) *TrError

Unauthenticated returns unauthenticated Error

func Unavailable

func Unavailable(reason string, args ...interface{}) *TrError

Unavailable return service unavailable Error

func Unimplemented

func Unimplemented(reason string, args ...interface{}) *TrError

Unimplemented return unimplemented Error

func Unknown

func Unknown(reason string, args ...interface{}) *TrError

Unknown returns unknown Error

func (*TrError) Error

func (te *TrError) Error() string

func (*TrError) GRPCStatus

func (te *TrError) GRPCStatus() *status.Status

GRPCStatus 需要继承该方法,才能正常返回应用定义的错误码

func (*TrError) GetCodeInt

func (te *TrError) GetCodeInt() int

GetCodeInt 建议使用,获取int类型的错误码

func (*TrError) GetCodeInt32

func (te *TrError) GetCodeInt32() int32

GetCodeInt32 建议使用,获取int32类型的错误码

func (*TrError) GetMessage

func (te *TrError) GetMessage() string

GetMessage 建议使用,获取错误消息

Directories

Path Synopsis
Package codes provide codes list
Package codes provide codes list

Jump to

Keyboard shortcuts

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