mirror of
https://github.com/pyihe/go-pkg.git
synced 2025-10-06 16:36:50 +08:00
36 lines
482 B
Go
36 lines
482 B
Go
package errors
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
const (
|
|
DefaultErrCode ErrorCode = 100000
|
|
)
|
|
|
|
type ErrorCode int64
|
|
|
|
func NewErrCode(code int64) ErrorCode {
|
|
return ErrorCode(code)
|
|
}
|
|
|
|
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
|
|
}
|