1 // Copyright 2018 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
9 // Errorf formats according to a format specifier and returns the string as a
10 // value that satisfies error.
12 // If the format specifier includes a %w verb with an error operand,
13 // the returned error will implement an Unwrap method returning the operand. It is
14 // invalid to include more than one %w verb or to supply it with an operand
15 // that does not implement the error interface. The %w verb is otherwise
17 func Errorf(format
string, a
...any
) error
{
23 if p
.wrappedErr
== nil {
26 err
= &wrapError
{s
, p
.wrappedErr
}
32 type wrapError
struct {
37 func (e
*wrapError
) Error() string {
41 func (e
*wrapError
) Unwrap() error
{