mirror of
https://github.com/e1732a364fed/v2ray_simple.git
synced 2025-11-02 12:54:15 +08:00
将common包改名为utils, 因为common太长了
This commit is contained in:
43
utils/error.go
Normal file
43
utils/error.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package utils
|
||||
|
||||
import "fmt"
|
||||
|
||||
type ErrInErr struct {
|
||||
ErrDesc string
|
||||
ErrDetail error
|
||||
Data interface{}
|
||||
}
|
||||
|
||||
func (e *ErrInErr) String() string {
|
||||
if e.Data != nil {
|
||||
|
||||
if e.ErrDetail != nil {
|
||||
return fmt.Sprintf("%s : %s, Data: %v", e.ErrDesc, e.ErrDetail.Error(), e.Data)
|
||||
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s , Data: %v", e.ErrDesc, e.Data)
|
||||
|
||||
}
|
||||
return fmt.Sprintf("%s : %s", e.ErrDesc, e.ErrDetail.Error())
|
||||
|
||||
}
|
||||
|
||||
func (e *ErrInErr) Error() string {
|
||||
return e.String()
|
||||
}
|
||||
|
||||
func NewErr(desc string, e error) *ErrInErr {
|
||||
return &ErrInErr{
|
||||
ErrDesc: desc,
|
||||
ErrDetail: e,
|
||||
}
|
||||
}
|
||||
|
||||
func NewDataErr(desc string, e error, data interface{}) *ErrInErr {
|
||||
return &ErrInErr{
|
||||
ErrDesc: desc,
|
||||
ErrDetail: e,
|
||||
Data: data,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user