From 0fb1a7b650853bfa3d870498c1b30f97ce11a11c Mon Sep 17 00:00:00 2001 From: PatrickMenoti <82882574+PatrickMenoti@users.noreply.github.com> Date: Mon, 17 Jun 2024 10:08:56 -0300 Subject: [PATCH] chore: update error formatting --- messages/manifest/errors.go | 12 ++++++------ pkg/manifest/manifest.go | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/messages/manifest/errors.go b/messages/manifest/errors.go index a72e850b..8dee1b71 100644 --- a/messages/manifest/errors.go +++ b/messages/manifest/errors.go @@ -7,10 +7,10 @@ var ( ErrorCacheNotFound = errors.New("Could not find this cache setting") ErrorFunctionNotFound = errors.New("Could not find this edge function") ErrorOriginNotFound = errors.New("Could not find this origin") - ErrorCreateOrigin = errors.New("Failed to create the origin: %s") - ErrorCreateCache = errors.New("Failed to create the cache setting: %s") - ErrorCreateRule = errors.New("Failed to create the rule in Rules Engine: %s") - ErrorUpdateOrigin = errors.New("Failed to update the origin: %s") - ErrorUpdateCache = errors.New("Failed to update the cache setting: %s") - ErrorUpdateRule = errors.New("Failed to update the rule in Rules Engine: %s") + ErrorCreateOrigin = errors.New("Failed to create the origin") + ErrorCreateCache = errors.New("Failed to create the cache setting") + ErrorCreateRule = errors.New("Failed to create the rule in Rules Engine") + ErrorUpdateOrigin = errors.New("Failed to update the origin") + ErrorUpdateCache = errors.New("Failed to update the cache setting") + ErrorUpdateRule = errors.New("Failed to update the rule in Rules Engine") ) diff --git a/pkg/manifest/manifest.go b/pkg/manifest/manifest.go index 937d7485..2e35cb30 100644 --- a/pkg/manifest/manifest.go +++ b/pkg/manifest/manifest.go @@ -112,7 +112,7 @@ func (man *ManifestInterpreter) CreateResources(conf *contracts.AzionApplication } updated, err := clientOrigin.Update(ctx, conf.Application.ID, OriginKeys[origin.Name], requestUpdate) if err != nil { - return fmt.Errorf(msg.ErrorUpdateOrigin.Error(), err.Error()) + return fmt.Errorf("%w: %s", msg.ErrorUpdateOrigin, err.Error()) } newEntry := contracts.AzionJsonDataOrigin{ @@ -131,7 +131,7 @@ func (man *ManifestInterpreter) CreateResources(conf *contracts.AzionApplication } created, err := clientOrigin.Create(ctx, conf.Application.ID, requestCreate) if err != nil { - return fmt.Errorf(msg.ErrorCreateOrigin.Error(), err.Error()) + return fmt.Errorf("%w: %s", msg.ErrorCreateOrigin, err.Error()) } newOrigin := contracts.AzionJsonDataOrigin{ OriginId: created.GetOriginId(), @@ -164,7 +164,7 @@ func (man *ManifestInterpreter) CreateResources(conf *contracts.AzionApplication } updated, err := clientCache.Update(ctx, requestUpdate, conf.Application.ID, id) if err != nil { - return fmt.Errorf(msg.ErrorUpdateCache.Error(), err.Error()) + return fmt.Errorf("%w: %s", msg.ErrorUpdateCache, err.Error()) } newCache := contracts.AzionJsonDataCacheSettings{ Id: updated.GetId(), @@ -181,7 +181,7 @@ func (man *ManifestInterpreter) CreateResources(conf *contracts.AzionApplication } created, err := clientCache.Create(ctx, requestUpdate, conf.Application.ID) if err != nil { - return fmt.Errorf(msg.ErrorCreateCache.Error(), err.Error()) + return fmt.Errorf("%w: %s", msg.ErrorCreateCache, err.Error()) } newCache := contracts.AzionJsonDataCacheSettings{ Id: created.GetId(), @@ -219,7 +219,7 @@ func (man *ManifestInterpreter) CreateResources(conf *contracts.AzionApplication requestUpdate.IdApplication = conf.Application.ID updated, err := client.UpdateRulesEngine(ctx, requestUpdate) if err != nil { - return fmt.Errorf(msg.ErrorUpdateRule.Error(), err.Error()) + return fmt.Errorf("%w: %s", msg.ErrorUpdateRule, err.Error()) } newRule := contracts.AzionJsonDataRules{ Id: updated.GetId(), @@ -242,7 +242,7 @@ func (man *ManifestInterpreter) CreateResources(conf *contracts.AzionApplication requestCreate.Order = &rule.Order created, err := client.CreateRulesEngine(ctx, conf.Application.ID, rule.Phase, requestCreate) if err != nil { - return fmt.Errorf(msg.ErrorCreateRule.Error(), err.Error()) + return fmt.Errorf("%w: %s", msg.ErrorCreateRule, err.Error()) } newRule := contracts.AzionJsonDataRules{ Id: created.GetId(),