errorskratos

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2026 License: MIT Imports: 1 Imported by: 2

Documentation

Overview

Package errorskratos provides type-safe helpers to handle Kratos errors, avoiding naming conflicts with the standard errors package.

errorskratos 提供 Kratos 错误的类型安全辅助函数,避免与标准 errors 包命名冲突。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func As

func As(err error) (erk *errors.Error, ok bool)

As converts a generic error to a Kratos error and reports success.

As 把通用 error 转成 Kratos 错误,并返回是否成功。

func From

func From(err error) *errors.Error

From is a short alias of FromError.

From 是 FromError 的简短别名。

func FromError

func FromError(err error) *errors.Error

FromError converts a plain error to the Kratos error type.

FromError 把普通 error 转成 Kratos 错误类型。

func Is

func Is(erk1 *errors.Error, erk2 *errors.Error) bool

Is reports if two Kratos errors match, handling nil on both sides.

Is 判断两个 Kratos 错误是否一致,两侧 nil 都安全处理。

Types

type Erk

type Erk = errors.Error

Erk aliases errors.Error to sidestep conflicts with the standard errors package.

Erk 是 errors.Error 的别名,避免与标准 errors 包命名冲突。

Directories

Path Synopsis
Package erkadapt converts a Kratos error to the standard error interface with correct nil semantics, sidestepping Go's (*T)(nil) != nil trap.
Package erkadapt converts a Kratos error to the standard error interface with correct nil semantics, sidestepping Go's (*T)(nil) != nil trap.
must
erkassert
Package erkassert wraps testify/assert to test Kratos errors, handling the nil interface trap via erkadapt.
Package erkassert wraps testify/assert to test Kratos errors, handling the nil interface trap via erkadapt.
erkmust
Package erkmust panics on a non-nil Kratos error, logging it first.
Package erkmust panics on a non-nil Kratos error, logging it first.
erkrequire
Package erkrequire wraps testify/require to test Kratos errors, handling the nil interface trap via erkadapt.
Package erkrequire wraps testify/require to test Kratos errors, handling the nil interface trap via erkadapt.

Jump to

Keyboard shortcuts

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