Documentation ¶
Index ¶
- Constants
- Variables
- func Example()
- func Internal(err error, format string, args ...interface{}) error
- func Is(err error, code string) bool
- func New(code, format string, args ...interface{}) error
- func NewCode(err error, code, format string, args ...interface{}) error
- func Parse(err error) (code, message string)
- func ParseAndWrap(err error, format string, args ...interface{}) error
- func TryParseFromString(s string) (code, message string, success bool)
- func Wrap(err error, format string, args ...interface{}) error
- type Error
Constants ¶
View Source
const ( ErrCodeInternal = "10001" // internal error ErrCodeParam = "10002" // parameter error ErrCodeConfig = "10003" // configuration error ErrCodeNotFound = "10004" // target not found ErrCodeEncoding = "10005" // encoding error ErrCodeNotAuthorized = "10006" // not authorized ErrCodeAlreadyExists = "10007" // duplicate item ErrCodeBadSignature = "10008" // signature verification failed ErrCodeCrypto = "10009" // cryptography computation error ErrCodeExpired = "10010" // target expired ErrCodeReadBlockchain = "10011" // errors occurred when reading data from blockchain ErrCodeWriteBlockchain = "10012" // errors occurred when writing data to blockchain ErrCodeAlreadyUpdate = "10013" // duplicate updating error )
error code list
View Source
const SuccessCode = "0"
define success code
Variables ¶
View Source
var ErrNotFound = &Error{ Code: ErrCodeNotFound, Message: "not found", }
Functions ¶
func NewCode ¶
NewCode Create an error by wrapping a existed error from outer package
will drop original code
func Parse ¶
Parse retrieve code and message 1. try to retrieve errorx.Error from err chain 2. try to unmarshal err.Error() into errorx.Error 3. or else an internal error with original err.Error()
func ParseAndWrap ¶
ParseAndWrap decode and wrap errors from outer components
func TryParseFromString ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.