internal/mcp/jsonschema: generalize error wrapping
Add a wrapf function to simplify defers that wrap errors. Change-Id: If4bedec7d3f56f609d3ca4620aebe7637a59f6bf Reviewed-on: https://go-review.googlesource.com/c/tools/+/676475 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
parent
e3938ce68c
commit
4e9d520c2e
1 changed files with 9 additions and 10 deletions
|
|
@ -42,11 +42,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 func() {
|
||||
if err != nil {
|
||||
err = fmt.Errorf("%s: %w", schema, err)
|
||||
}
|
||||
}()
|
||||
defer wrapf(&err, "validating %s", schema)
|
||||
|
||||
st.stack = append(st.stack, schema) // push
|
||||
defer func() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue