From b2d0c28cc59b4d683808f4d759e793571717982f Mon Sep 17 00:00:00 2001 From: liuxingyu9574 <841528039@qq.com> Date: Tue, 30 Jul 2024 21:51:31 +0800 Subject: [PATCH] fix: return more detailed error msg with JsonPatch --- pkg/modules/generators/app_configurations_generator.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/modules/generators/app_configurations_generator.go b/pkg/modules/generators/app_configurations_generator.go index ebc188572..cd949e969 100644 --- a/pkg/modules/generators/app_configurations_generator.go +++ b/pkg/modules/generators/app_configurations_generator.go @@ -197,7 +197,7 @@ func JSONPatch(resources v1.Resources, patcher *v1.Patcher) error { case v1.MergePatch: modified, err := jsonpatch.MergePatch([]byte(target), jsonPatcher.Payload) if err != nil { - return fmt.Errorf("merge patch to:%s failed", id) + return fmt.Errorf("merge patch to:%s failed with error %w", id, err) } if err = json.Unmarshal(modified, &res.Attributes); err != nil { return err @@ -205,12 +205,12 @@ func JSONPatch(resources v1.Resources, patcher *v1.Patcher) error { case v1.JSONPatch: patch, err := jsonpatch.DecodePatch(jsonPatcher.Payload) if err != nil { - return fmt.Errorf("decode json patch:%s failed", jsonPatcher.Payload) + return fmt.Errorf("decode json patch:%s failed with error %w", jsonPatcher.Payload, err) } modified, err := patch.Apply([]byte(target)) if err != nil { - return fmt.Errorf("apply json patch to:%s failed", id) + return fmt.Errorf("apply json patch to:%s failed with error %w", id, err) } if err = json.Unmarshal(modified, &res.Attributes); err != nil { return err