refactor(errors): change errors

This commit is contained in:
pyihe
2021-07-13 17:44:54 +08:00
parent a20ace4425
commit c5eb321de9
7 changed files with 122 additions and 81 deletions

31
errors/code.go Normal file
View File

@@ -0,0 +1,31 @@
package errors
import (
"fmt"
)
const (
DefaultErrCode ErrorCode = -1
)
type ErrorCode int64
func (ec ErrorCode) Int() int {
return int(ec)
}
func (ec ErrorCode) Int64() int64 {
return int64(ec)
}
func (ec ErrorCode) Int32() int32 {
return int32(ec)
}
func (ec ErrorCode) ToString() string {
return fmt.Sprintf("%d", ec)
}
func (ec ErrorCode) Equal(target ErrorCode) bool {
return ec == target
}