- add callback sign check.
This commit is contained in:
38
utils/errorwithcode.go
Normal file
38
utils/errorwithcode.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type ErrorWithCode struct {
|
||||
str string
|
||||
code string
|
||||
intCode int
|
||||
}
|
||||
|
||||
func NewErrorCode(err, code string) *ErrorWithCode {
|
||||
return &ErrorWithCode{
|
||||
str: err,
|
||||
code: code,
|
||||
intCode: Str2Int(code),
|
||||
}
|
||||
}
|
||||
|
||||
func NewErrorIntCode(err string, code int) *ErrorWithCode {
|
||||
return &ErrorWithCode{
|
||||
str: err,
|
||||
code: Int2Str(code),
|
||||
intCode: code,
|
||||
}
|
||||
}
|
||||
func (e *ErrorWithCode) Error() string {
|
||||
return fmt.Sprintf("%s, code:%s", e.str, e.code)
|
||||
}
|
||||
|
||||
func (e *ErrorWithCode) Code() string {
|
||||
return e.code
|
||||
}
|
||||
|
||||
func (e *ErrorWithCode) IntCode() int {
|
||||
return e.intCode
|
||||
}
|
||||
Reference in New Issue
Block a user