internal/mcp/internal/util: add Wrapf
Add Wrapf, a function that helps with error wrapping. Change-Id: I102695f75e4d217e09f828f4723cbfcbbe83f887 Reviewed-on: https://go-review.googlesource.com/c/tools/+/679177 Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Sam Thanawalla <samthanawalla@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
30af200d5e
commit
d9a7859c3b
1 changed files with 17 additions and 20 deletions
|
|
@ -73,7 +73,7 @@ type state struct {
|
|||
|
||||
// validate validates the reflected value of the instance.
|
||||
func (st *state) validate(instance reflect.Value, schema *Schema, callerAnns *annotations) (err error) {
|
||||
defer wrapf(&err, "validating %s", schema)
|
||||
defer util.Wrapf(&err, "validating %s", schema)
|
||||
|
||||
// Maintain a stack for dynamic schema resolution.
|
||||
st.stack = append(st.stack, schema) // push
|
||||
|
|
@ -607,7 +607,7 @@ func (rs *Resolved) ApplyDefaults(instancep any) error {
|
|||
// Leave this as a potentially recursive helper function, because we'll surely want
|
||||
// to apply defaults on sub-schemas someday.
|
||||
func (st *state) applyDefaults(instancep reflect.Value, schema *Schema) (err error) {
|
||||
defer wrapf(&err, "applyDefaults: schema %s, instance %v", schema, instancep)
|
||||
defer util.Wrapf(&err, "applyDefaults: schema %s, instance %v", schema, instancep)
|
||||
|
||||
instance := instancep.Elem()
|
||||
if instance.Kind() == reflect.Map || instance.Kind() == reflect.Struct {
|
||||
|
|
|
|||
Loading…
Reference in a new issue