Some checks are pending
Security Checks / security (push) Waiting to run
统一 frontend、backend、test、test-log 和 out 目录,更新构建、部署及测试入口;纳入配置管理兼容与首次安全引导修复;排除本机配置、密钥和测试产物。
35 lines
653 B
Go
35 lines
653 B
Go
package errors
|
|
|
|
import (
|
|
oe "errors"
|
|
"fmt"
|
|
"runtime"
|
|
)
|
|
|
|
func New(text string) error {
|
|
_, file, line, _ := runtime.Caller(1)
|
|
return oe.New(fmt.Sprintf("%s at %s:%d", text, file, line))
|
|
}
|
|
|
|
func Wrap(err error) error {
|
|
_, file, line, _ := runtime.Caller(1)
|
|
return fmt.Errorf("at %s:%d\n%w", file, line, err)
|
|
}
|
|
|
|
func WrapWithMsg(err error, msg string) error {
|
|
_, file, line, _ := runtime.Caller(1)
|
|
return fmt.Errorf("%s at %s:%d\n%w", msg, file, line, err)
|
|
}
|
|
|
|
func Unwrap(err error) error {
|
|
return oe.Unwrap(err)
|
|
}
|
|
|
|
func Is(err, target error) bool {
|
|
return oe.Is(err, target)
|
|
}
|
|
|
|
func As(err error, target any) bool {
|
|
return oe.As(err, target)
|
|
}
|