2022-10-26 12:23:12 +00:00
|
|
|
package logicerr
|
|
|
|
|
2022-10-31 07:02:30 +00:00
|
|
|
import "errors"
|
|
|
|
|
2022-10-26 12:23:12 +00:00
|
|
|
// Logical is a wrapper for logical errors.
|
|
|
|
type Logical struct {
|
|
|
|
err error
|
|
|
|
}
|
|
|
|
|
2022-10-31 07:02:30 +00:00
|
|
|
// New returns simple error with a provided error message.
|
|
|
|
func New(msg string) Logical {
|
|
|
|
return Wrap(errors.New(msg))
|
|
|
|
}
|
|
|
|
|
2022-10-26 12:23:12 +00:00
|
|
|
// Error implements the error interface.
|
|
|
|
func (e Logical) Error() string {
|
|
|
|
return e.err.Error()
|
|
|
|
}
|
|
|
|
|
|
|
|
// Wrap wraps arbitrary error into a logical one.
|
|
|
|
func Wrap(err error) Logical {
|
|
|
|
return Logical{err: err}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Unwrap returns underlying error.
|
|
|
|
func (e Logical) Unwrap() error {
|
|
|
|
return e.err
|
|
|
|
}
|