mirror of
https://github.com/muun/recovery.git
synced 2025-07-20 22:11:16 -04:00
29 lines
407 B
Go
29 lines
407 B
Go
package errors
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
)
|
|
|
|
type Error struct {
|
|
err error
|
|
code int64
|
|
}
|
|
|
|
func (e *Error) Error() string {
|
|
return e.err.Error()
|
|
}
|
|
|
|
func (e *Error) Code() int64 {
|
|
return e.code
|
|
}
|
|
|
|
func New(code int64, msg string) error {
|
|
return &Error{errors.New(msg), code}
|
|
}
|
|
|
|
func Errorf(code int64, format string, a ...interface{}) error {
|
|
err := fmt.Errorf(format, a...)
|
|
return &Error{err, code}
|
|
}
|