erm/app/darktile/config/errors.go
2024-02-07 17:43:18 -06:00

35 lines
557 B
Go

package config
import (
"errors"
"fmt"
)
var ErrWrongType = errors.New("wrong type")
var ErrNotFound = errors.New("not found")
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)
}