You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
488 B
Go
28 lines
488 B
Go
package wire
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
)
|
|
|
|
type Error struct {
|
|
Message string `json:"message"`
|
|
parent error
|
|
}
|
|
|
|
func (e Error) Error() string { return e.Message }
|
|
func (e Error) NetTag() string { return "error" }
|
|
func (e Error) Unwrap() error { return e.parent }
|
|
|
|
func Errorf(t string, args ...interface{}) Error {
|
|
err := fmt.Errorf(t, args...)
|
|
return Error{
|
|
Message: err.Error(),
|
|
parent: errors.Unwrap(err),
|
|
}
|
|
}
|
|
|
|
func init() {
|
|
Register(func() Value { return new(Error) })
|
|
}
|