newerk

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetReasonCodeFieldName

func GetReasonCodeFieldName() string

GetReasonCodeFieldName returns the current reason code field name

GetReasonCodeFieldName 返回当前的原因码字段名

func IsError

func IsError[E ProtoErrorEnum](err error, enum E, httpCode int) bool

IsError checks if the given error matches the specified enum and HTTP code

IsError 检查给定错误是否匹配指定的枚举和 HTTP 代码

func NewError

func NewError[E ProtoErrorEnum](httpCode int, enum E, format string, args ...interface{}) *errors.Error

NewError creates a new error with the specified parameters If reason code field name is configured, adds enum numeric value to metadata

NewError 创建带指定参数的新错误 如果配置了原因码字段名,则将枚举数值添加到 metadata

func SetReasonCodeFieldName

func SetReasonCodeFieldName(fieldName string)

SetReasonCodeFieldName sets the metadata field name for storing enum numeric value This field bridges Kratos string reason and frontend numeric enum

SetReasonCodeFieldName 设置用于存储枚举数值的 metadata 字段名 此字段用于桥接 Kratos 字符串 reason 和前端数字枚举

Types

type Config

type Config struct {
	ReasonCodeFieldName string // Metadata field name for storing enum numeric value // 存储枚举数值的 metadata 字段名
}

Config for error generation

Config 错误生成配置

type ProtoErrorEnum

type ProtoErrorEnum interface {
	String() string
	Number() protoreflect.EnumNumber
}

ProtoErrorEnum constraint for protobuf generated enum types

ProtoErrorEnum protobuf 生成的枚举类型约束

Jump to

Keyboard shortcuts

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