Test if Unwrap method is supported is added.

This commit is contained in:
Foil-hat-guy 2025-05-05 01:22:01 +03:00
parent f10f105886
commit e7b4f5344e
No known key found for this signature in database
GPG key ID: 221CC305A7B23591

View file

@ -4,8 +4,25 @@ import(
"fmt"
)
type unwraperr interface {
Unwrap() error
}
type unwraperrs interface {
Unwrap() []error
}
func isUnwrapable(err error) bool {
_, ok1 := err.(unwraperr)
_, ok2 := err.(unwraperrs)
return ok1 || ok2
}
func errStack(err1 error, err2 error) error {
return fmt.Errorf("%w: %w", err1, err2)
if isUnwrapable(err2) {
return fmt.Errorf("%w: %w", err1, err2)
}
return fmt.Errorf("%w: %v", err1, err2)
}
func ERR_NOT_TTY() error {