util/vizerror: add As function to get wrapped Error

Signed-off-by: Will Norris <will@tailscale.com>
This commit is contained in:
Will Norris
2023-02-01 14:07:24 -08:00
committed by Will Norris
parent 51e1ab5560
commit 10085063fb
3 changed files with 21 additions and 2 deletions

View File

@@ -42,3 +42,9 @@ func Wrap(err error) error {
}
return Error{err}
}
// As returns the first vizerror.Error in err's chain.
func As(err error) (e Error, ok bool) {
ok = errors.As(err, &e)
return
}