xerror

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: BSD-3-Clause-Clear Imports: 3 Imported by: 0

Documentation

Overview

自定义错误处理包,支持记录错误的发生我位置、发生行数等信息

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(msg string) error

新建错误消息

msg	错误消息

func NewError added in v0.2.18

func NewError(msg string, err error) error

新建错误信息

msg	错误提示
err	错误信息

func NewFmt added in v0.2.22

func NewFmt(msg string, param ...any) error

新建错误消息-带参数格式化形式

msg		错误消息
param	传入参数

func To added in v0.2.20

func To(err error) error

将error错误信息转换为xerror.XError对象,便于更加完善的错误记录 自动判定,如果err为xerror.XError对象,则会直接将err进行返回,并不会做进一步封装

err	待转换的错误对象

Types

type XError

type XError struct {
	File   string `json:"file" form:"file"`     // 错误文件
	Line   int    `json:"line" form:"line"`     // 错误行数
	Errors string `json:"errors" form:"errors"` // 错误信息
}

定义错误结构体,此结构体直接使用F公共变量,以便使用时直接调用,而不需要再行获取

func (*XError) Error

func (c *XError) Error() string

错误信息输出

func (*XError) ErrorInfo

func (c *XError) ErrorInfo() string

输出详细的字符串信息

Jump to

Keyboard shortcuts

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