1 Star 0 Fork 0

iceinto/gfutil

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
gerror_api_option.go 1.12 KB
一键复制 编辑 原始数据 按行查看 历史
iceinto 提交于 2024-09-13 17:50 . v2 版本位置调整
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://github.com/elastic/beats/v7/kspkg/gf.
package gerror
import "gitee.com/iceinto/gfutil/v2/errors/gcode"
// Option is option for creating error.
type Option struct {
Error error // Wrapped error if any.
Stack bool // Whether recording stack information into error.
Text string // Error text, which is created by New* functions.
Code gcode.Code // Error code if necessary.
}
// NewWithOption creates and returns a custom error with Option.
// It is the senior usage for creating error, which is often used internally in framework.
func NewWithOption(option Option) error {
err := &Error{
error: option.Error,
text: option.Text,
code: option.Code,
}
if option.Stack {
err.stack = callers()
}
return err
}
// NewOption creates and returns a custom error with Option.
// Deprecated: use NewWithOption instead.
func NewOption(option Option) error {
return NewWithOption(option)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/iceinto/gfutil.git
git@gitee.com:iceinto/gfutil.git
iceinto
gfutil
gfutil
v2.0.0

搜索帮助