mirror of
https://github.com/tailscale/tailscale.git
synced 2025-02-20 11:58:39 +00:00
fixup! util/vizerror: add new package for visible errors
Signed-off-by: Will Norris <will@tailscale.com>
This commit is contained in:
parent
598ec463bc
commit
a6c6979b85
@ -20,13 +20,13 @@ func (e Error) Error() string {
|
|||||||
return e.err.Error()
|
return e.err.Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
// New returns an Error that formats as the given text.
|
// New returns an error that formats as the given text. Always returns a vizerror.Error.
|
||||||
func New(text string) Error {
|
func New(text string) error {
|
||||||
return Error{errors.New(text)}
|
return Error{errors.New(text)}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Errorf returns an Error with the specified format and values.
|
// Errorf returns an Error with the specified format and values. Always returns a vizerror.Error.
|
||||||
func Errorf(format string, a ...any) Error {
|
func Errorf(format string, a ...any) error {
|
||||||
return Error{fmt.Errorf(format, a...)}
|
return Error{fmt.Errorf(format, a...)}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,6 +36,9 @@ func (e Error) Unwrap() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Wrap err with a vizerror.Error.
|
// Wrap err with a vizerror.Error.
|
||||||
func Wrap(err error) Error {
|
func Wrap(err error) error {
|
||||||
|
if err == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return Error{err}
|
return Error{err}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user