trerror

package
v1.30.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2025 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

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

Variables

View Source
var (
	TR_SUCCESS               = &TrError{codes.TrSuccess, "成功"}
	TR_BAD_REQUEST           = &TrError{codes.TrBadRequest, "无效的请求"}
	TR_ERROR                 = &TrError{codes.TrError, "服务器错误"}
	TR_INVALID_ERROR         = &TrError{codes.TrInvalidError, "未知的错误类型"}
	TR_INVALID_TOKEN         = &TrError{codes.TrInvalidToken, "无效token"}
	TR_FILE_TOO_LARGE        = &TrError{codes.TrFileTooLarge, "文件过大"}
	TR_DUPLICATE_PRIMARY_KEY = &TrError{codes.TrDuplicatePrimaryKey, "重复主键"}
	TR_LOGIN_ERROR           = &TrError{codes.TrLoginError, "登录错误"}
	TR_NOT_LOGIN             = &TrError{codes.TrNotLogin, "请登录"}
	TR_USER_NOT_EXIST        = &TrError{codes.TrUserNotExist, "用户不存在"}
	TR_DISABLED_USER         = &TrError{codes.TrDisableUser, "用户已被禁用"}
	TR_WRONG_PASSWORD        = &TrError{codes.TrWrongPassword, "密码错误"}
	TR_NO_PERMISSION         = &TrError{codes.TrNoPermission, "无权限"}
	TR_ILLEGAL_OPERATION     = &TrError{codes.TrIllegalOperation, "非法操作"}
	TR_RECORD_NOT_FOUND      = &TrError{codes.TrRecordNotFound, "记录不存在"}
	TR_LOGIN_UNSUPPORT       = &TrError{codes.TrLoginUnSupport, "暂不支持此方式登录"}

	TR_SYSTEM_ERROR = &TrError{codes.TrSystemError, "系统错误"}
	TR_SYSTEM_BUSY  = &TrError{codes.TrSystemBusy, "系统繁忙"}
	TR_TIMEOUT      = &TrError{codes.TrTimeout, "请求超时"}

	// ugc校验错误
	ContentIllegal = &TrError{codes.TrContentIllegal, "文字包含违规信息"}
	ImageIllegal   = &TrError{codes.TrImageIllegal, "图片包含违规信息"}
	VideoIllegal   = &TrError{codes.TrVideoIllegal, "视频包含违规信息"}

	// 数据库错误
	TR_DB_ERROR     = &TrError{codes.TrDbError, "数据库错误"}
	DBNotFoundError = &TrError{codes.TrDataNotFound, "未找到数据"}

	TR_ACCESS_TOO_FREQUENTLY = &TrError{codes.TrAccessTooFrequently, "访问太频繁"}
)

Functions

func WithOutNotFound added in v1.16.0

func WithOutNotFound(err error) error

WithOutNotFound Support skipping 'no record found' for list classes and setting the judgment operation for empty lists

Types

type TrError

type TrError struct {
	Code    int32
	Message string
}

func DefaultTrError

func DefaultTrError(msg string) *TrError

func New

func New(code int32, message string) *TrError

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

func NewErrorWithF

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

NewErrorWithF Error with reason fmt

func NewF

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

NewF Error with reason fmt

func NewTrError

func NewTrError(code int32, msg string) *TrError

func (*TrError) Error

func (te *TrError) Error() string

func (*TrError) GRPCStatus

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

No need to call, only inherit from 'type grpcstatus interface {GRPCStatus () * Status}', ensure that the returned application error code is correct

func (*TrError) GetCodeInt

func (te *TrError) GetCodeInt() int

GetCodeInt Suggest using to obtain error codes of type int

func (*TrError) GetCodeInt32

func (te *TrError) GetCodeInt32() int32

GetCodeInt32 Suggest using to obtain error codes of type int32

func (*TrError) GetMessage

func (te *TrError) GetMessage() string

GetMessage Suggested use to obtain error messages

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