erm/app/darktile/config/errors.go

35 lines
557 B
Go
Raw Permalink Normal View History

2021-07-30 22:29:20 +00:00
package config
import (
"errors"
"fmt"
)
2024-02-07 23:43:18 +00:00
var ErrWrongType = errors.New("wrong type")
var ErrNotFound = errors.New("not found")
2021-07-30 22:29:20 +00:00
type RecoverableError struct {
msg string
inner error
}
func NewRecoverableError(msg string, cause error) *RecoverableError {
return &RecoverableError{
inner: cause,
msg: msg,
}
}
func IsErrRecoverable(err error) bool {
var rec *RecoverableError
return errors.As(err, &rec)
}
func (e *RecoverableError) Error() string {
if e.inner == nil {
return e.msg
}
return fmt.Sprintf("%s: %s", e.msg, e.inner)
}