From 16230fc661f12983617b057b028008bac90e23ff Mon Sep 17 00:00:00 2001 From: Lukasz Zajaczkowski Date: Wed, 16 Nov 2022 09:04:18 +0100 Subject: [PATCH] improve GraphQL error handling (#277) --- cmd/plural/api.go | 18 +++++++++--------- cmd/plural/bundle.go | 4 ++-- cmd/plural/deploy.go | 16 ++++++++-------- cmd/plural/init.go | 8 ++++---- cmd/plural/packages.go | 8 +++++--- cmd/plural/push.go | 9 +++++---- cmd/plural/repos.go | 7 ++++--- cmd/plural/shell.go | 5 +++-- cmd/plural/validation.go | 2 +- go.mod | 4 ++-- pkg/api/client.go | 28 ++++++++++++++++++++++++++++ pkg/bundle/installer.go | 4 ++-- pkg/bundle/oidc.go | 8 ++++---- pkg/bundle/stack.go | 2 +- pkg/crypto/age.go | 7 +++++-- pkg/pluralfile/attrs.go | 3 ++- pkg/pluralfile/lock.go | 2 +- pkg/pluralfile/stack.go | 2 +- pkg/pluralfile/tags.go | 2 +- pkg/provider/provider.go | 4 ++-- pkg/scaffold/creator.go | 2 +- pkg/template/funcs.go | 6 +++++- pkg/wkspace/builder.go | 2 +- pkg/wkspace/graph.go | 2 +- 24 files changed, 98 insertions(+), 57 deletions(-) diff --git a/cmd/plural/api.go b/cmd/plural/api.go index 5dc09702..68595945 100644 --- a/cmd/plural/api.go +++ b/cmd/plural/api.go @@ -78,7 +78,7 @@ func (p *Plural) handleInstallations(c *cli.Context) error { p.InitPluralClient() installations, err := p.GetInstallations() if err != nil { - return err + return api.GetErrorResponse(err, "GetInstallations") } installations = algorithms.Filter(installations, func(v *api.Installation) bool { @@ -100,7 +100,7 @@ func (p *Plural) handleCharts(c *cli.Context) error { p.InitPluralClient() charts, err := p.GetCharts(c.Args().First()) if err != nil { - return err + return api.GetErrorResponse(err, "GetCharts") } headers := []string{"Id", "Name", "Description", "Latest Version"} @@ -113,7 +113,7 @@ func (p *Plural) handleTerraforma(c *cli.Context) error { p.InitPluralClient() tfs, err := p.GetTerraforma(c.Args().First()) if err != nil { - return err + return api.GetErrorResponse(err, "GetTerraforma") } headers := []string{"Id", "Name", "Description"} @@ -125,9 +125,8 @@ func (p *Plural) handleTerraforma(c *cli.Context) error { func (p *Plural) handleVersions(c *cli.Context) error { p.InitPluralClient() versions, err := p.GetVersions(c.Args().First()) - if err != nil { - return err + return api.GetErrorResponse(err, "GetVersions") } headers := []string{"Id", "Version"} @@ -140,7 +139,7 @@ func (p *Plural) handleChartInstallations(c *cli.Context) error { p.InitPluralClient() chartInstallations, err := p.GetChartInstallations(c.Args().First()) if err != nil { - return err + return api.GetErrorResponse(err, "GetChartInstallations") } cis := algorithms.Filter(chartInstallations, func(ci *api.ChartInstallation) bool { @@ -158,7 +157,7 @@ func (p *Plural) handleTerraformInstallations(c *cli.Context) error { p.InitPluralClient() terraformInstallations, err := p.GetTerraformInstallations(c.Args().First()) if err != nil { - return err + return api.GetErrorResponse(err, "GetTerraformInstallations") } tis := algorithms.Filter(terraformInstallations, func(ti *api.TerraformInstallation) bool { @@ -176,7 +175,7 @@ func (p *Plural) handleArtifacts(c *cli.Context) error { p.InitPluralClient() artifacts, err := p.ListArtifacts(c.Args().First()) if err != nil { - return err + return api.GetErrorResponse(err, "ListArtifacts") } headers := []string{"Id", "Name", "Platform", "Blob", "Sha"} @@ -187,5 +186,6 @@ func (p *Plural) handleArtifacts(c *cli.Context) error { func (p *Plural) handleCreateDomain(c *cli.Context) error { p.InitPluralClient() - return p.CreateDomain(c.Args().First()) + err := p.CreateDomain(c.Args().First()) + return api.GetErrorResponse(err, "CreateDomain") } diff --git a/cmd/plural/bundle.go b/cmd/plural/bundle.go index 9ee2661f..532ed926 100644 --- a/cmd/plural/bundle.go +++ b/cmd/plural/bundle.go @@ -73,7 +73,7 @@ func (p *Plural) bundleList(c *cli.Context) error { p.InitPluralClient() recipes, err := p.ListRecipes(repo, prov) if err != nil { - return err + return api.GetErrorResponse(err, "ListRecipes") } headers := []string{"Name", "Description", "Provider", "Install Command"} @@ -107,7 +107,7 @@ func (p *Plural) stackList(c *cli.Context) (err error) { p.InitPluralClient() stacks, err := p.ListStacks(c.Bool("account")) if err != nil { - return err + return api.GetErrorResponse(err, "ListStacks") } headers := []string{"Name", "Description", "Featured"} diff --git a/cmd/plural/deploy.go b/cmd/plural/deploy.go index 77f63148..16d1101c 100644 --- a/cmd/plural/deploy.go +++ b/cmd/plural/deploy.go @@ -28,7 +28,7 @@ func (p *Plural) getSortedInstallations(repo string) ([]*api.Installation, error p.InitPluralClient() installations, err := p.GetInstallations() if err != nil { - return installations, err + return installations, api.GetErrorResponse(err, "GetInstallations") } if len(installations) == 0 { @@ -47,7 +47,7 @@ func (p *Plural) allSortedRepos() ([]string, error) { p.InitPluralClient() insts, err := p.GetInstallations() if err != nil { - return nil, err + return nil, api.GetErrorResponse(err, "GetInstallations") } return wkspace.SortAndFilter(insts) @@ -103,7 +103,7 @@ func (p *Plural) build(c *cli.Context) error { if c.IsSet("only") { installation, err := p.GetInstallation(c.String("only")) if err != nil { - return err + return api.GetErrorResponse(err, "GetInstallation") } else if installation == nil { return utils.HighlightError(fmt.Errorf("%s is not installed. Please install it with `plural bundle install`", c.String("only"))) } @@ -162,7 +162,7 @@ func (p *Plural) validate(c *cli.Context) error { if c.IsSet("only") { installation, err := p.GetInstallation(c.String("only")) if err != nil { - return err + return api.GetErrorResponse(err, "GetInstallation") } return p.doValidate(installation) } @@ -237,7 +237,7 @@ func (p *Plural) deploy(c *cli.Context) error { installation, err := p.GetInstallation(repo) if err != nil { - return err + return api.GetErrorResponse(err, "GetInstallation") } if installation == nil { return fmt.Errorf("The %s was unistalled, run `plural bundle install %s ` ", repo, repo) @@ -327,7 +327,7 @@ func (p *Plural) bounce(c *cli.Context) error { if repoName != "" { installation, err := p.GetInstallation(repoName) if err != nil { - return err + return api.GetErrorResponse(err, "GetInstallation") } return p.doBounce(repoRoot, installation) } @@ -383,7 +383,7 @@ func (p *Plural) destroy(c *cli.Context) error { if repoName != "" { installation, err := p.GetInstallation(repoName) if err != nil { - return err + return api.GetErrorResponse(err, "GetInstallation") } return p.doDestroy(repoRoot, installation) @@ -450,7 +450,7 @@ func (p *Plural) buildContext(_ *cli.Context) error { p.InitPluralClient() insts, err := p.GetInstallations() if err != nil { - return err + return api.GetErrorResponse(err, "GetInstallation") } path := manifest.ContextPath() diff --git a/cmd/plural/init.go b/cmd/plural/init.go index b5e7f96f..2d367aac 100644 --- a/cmd/plural/init.go +++ b/cmd/plural/init.go @@ -104,7 +104,7 @@ func handleLogin(c *cli.Context) error { device, err := client.DeviceLogin() if err != nil { - return err + return api.GetErrorResponse(err, "DeviceLogin") } fmt.Printf("logging into Plural at %s\n", device.LoginUrl) @@ -132,7 +132,7 @@ func handleLogin(c *cli.Context) error { func postLogin(conf *config.Config, client api.Client, c *cli.Context) error { me, err := client.Me() if err != nil { - return err + return api.GetErrorResponse(err, "Me") } conf.Email = me.Email @@ -142,7 +142,7 @@ func postLogin(conf *config.Config, client api.Client, c *cli.Context) error { if saEmail != "" { jwt, email, err := client.ImpersonateServiceAccount(saEmail) if err != nil { - return err + return api.GetErrorResponse(err, "ImpersonateServiceAccount") } conf.Email = email @@ -153,7 +153,7 @@ func postLogin(conf *config.Config, client api.Client, c *cli.Context) error { accessToken, err := client.GrabAccessToken() if err != nil { - return err + return api.GetErrorResponse(err, "GrabAccessToken") } conf.Token = accessToken diff --git a/cmd/plural/packages.go b/cmd/plural/packages.go index 4b9f9b15..27fba71e 100644 --- a/cmd/plural/packages.go +++ b/cmd/plural/packages.go @@ -3,6 +3,8 @@ package main import ( "os" + "github.com/pluralsh/plural/pkg/api" + "github.com/olekukonko/tablewriter" "github.com/pluralsh/plural/pkg/utils" "github.com/pluralsh/plural/pkg/wkspace" @@ -61,7 +63,7 @@ func (p *Plural) uninstallPackage(c *cli.Context) error { if t == "terraform" { for _, inst := range space.Terraform { if inst.Terraform.Name == name { - return p.Client.UninstallTerraform(inst.Id) + return api.GetErrorResponse(p.Client.UninstallTerraform(inst.Id), "UninstallTerraform") } } } @@ -69,7 +71,7 @@ func (p *Plural) uninstallPackage(c *cli.Context) error { if t == "helm" { for _, inst := range space.Charts { if inst.Chart.Name == name { - return p.Client.UninstallChart(inst.Id) + return api.GetErrorResponse(p.Client.UninstallChart(inst.Id), "UninstallChart") } } } @@ -82,7 +84,7 @@ func (p *Plural) getWorkspace(repo string) (*wkspace.Workspace, error) { p.InitPluralClient() inst, err := p.Client.GetInstallation(repo) if err != nil { - return nil, err + return nil, api.GetErrorResponse(err, "GetInstallation") } return wkspace.New(p.Client, inst) diff --git a/cmd/plural/push.go b/cmd/plural/push.go index ab9ce2f1..1ca97fd6 100644 --- a/cmd/plural/push.go +++ b/cmd/plural/push.go @@ -93,7 +93,7 @@ func apply(c *cli.Context) error { func (p *Plural) handleTerraformUpload(c *cli.Context) error { p.InitPluralClient() _, err := p.UploadTerraform(c.Args().Get(0), c.Args().Get(1)) - return err + return api.GetErrorResponse(err, "UploadTerraform") } func handleHelmTemplate(c *cli.Context) error { @@ -190,7 +190,7 @@ func (p *Plural) handleRecipeUpload(c *cli.Context) error { } _, err = p.CreateRecipe(c.Args().Get(1), recipeInput) - return err + return api.GetErrorResponse(err, "CreateRecipe") } func (p *Plural) handleArtifact(c *cli.Context) error { @@ -208,7 +208,7 @@ func (p *Plural) handleArtifact(c *cli.Context) error { input.Platform = c.String("platform") input.Arch = c.String("arch") _, err = p.CreateArtifact(c.Args().Get(1), input) - return err + return api.GetErrorResponse(err, "CreateArtifact") } func (p *Plural) createCrd(c *cli.Context) error { @@ -216,5 +216,6 @@ func (p *Plural) createCrd(c *cli.Context) error { fullPath, _ := filepath.Abs(c.Args().Get(0)) repo := c.Args().Get(1) chart := c.Args().Get(2) - return p.CreateCrd(repo, chart, fullPath) + err := p.CreateCrd(repo, chart, fullPath) + return api.GetErrorResponse(err, "CreateCrd") } diff --git a/cmd/plural/repos.go b/cmd/plural/repos.go index be05c65a..27840191 100644 --- a/cmd/plural/repos.go +++ b/cmd/plural/repos.go @@ -45,14 +45,15 @@ func (p *Plural) reposCommands() []cli.Command { func (p *Plural) handleUnlockRepo(c *cli.Context) error { p.InitPluralClient() - return p.UnlockRepository(c.Args().First()) + err := p.UnlockRepository(c.Args().First()) + return api.GetErrorResponse(err, "UnlockRepository") } func (p *Plural) handleListRepositories(c *cli.Context) error { p.InitPluralClient() repos, err := p.ListRepositories(c.String("query")) if err != nil { - return err + return api.GetErrorResponse(err, "ListRepositories") } addIcon := c.String("format") == "csv" @@ -88,7 +89,7 @@ func (p *Plural) handleResetInstallations(c *cli.Context) error { p.InitPluralClient() count, err := p.ResetInstallations() if err != nil { - return err + return api.GetErrorResponse(err, "ResetInstallations") } fmt.Printf("Deleted %d installations in app.plural.sh\n", count) diff --git a/cmd/plural/shell.go b/cmd/plural/shell.go index a1b73024..f2d2aad2 100644 --- a/cmd/plural/shell.go +++ b/cmd/plural/shell.go @@ -46,7 +46,7 @@ func handleShellSync(c *cli.Context) error { shell, err := client.GetShell() if err != nil { - return err + return api.GetErrorResponse(err, "GetShell") } if err := crypto.Setup(shell.AesKey); err != nil { @@ -77,5 +77,6 @@ func handleShellPurge(c *cli.Context) error { } client := api.NewClient() - return client.DeleteShell() + err := client.DeleteShell() + return api.GetErrorResponse(err, "DeleteShell") } diff --git a/cmd/plural/validation.go b/cmd/plural/validation.go index 34c06a3b..7f6bc9b8 100644 --- a/cmd/plural/validation.go +++ b/cmd/plural/validation.go @@ -78,7 +78,7 @@ func tracked(fn func(*cli.Context) error, event string) func(*cli.Context) error if conf.ReportErrors { client := api.FromConfig(&conf) if err := client.CreateEvent(&event); err != nil { - return err + return api.GetErrorResponse(err, "CreateEvent") } } return err diff --git a/go.mod b/go.mod index 8abb2eae..62d74f90 100644 --- a/go.mod +++ b/go.mod @@ -18,6 +18,7 @@ require ( github.com/Azure/go-autorest/autorest/azure/auth v0.5.11 github.com/Azure/go-autorest/autorest/to v0.4.0 github.com/Masterminds/sprig/v3 v3.2.2 + github.com/Yamashou/gqlgenc v0.11.0 github.com/azure/azure-sdk-for-go v57.4.0+incompatible github.com/buger/goterm v1.0.4 github.com/chartmuseum/helm-push v0.10.3 @@ -61,7 +62,6 @@ require ( require ( github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1 // indirect - github.com/Yamashou/gqlgenc v0.11.0 // indirect github.com/aws/aws-sdk-go-v2 v1.16.14 // indirect github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.3 // indirect github.com/aws/aws-sdk-go-v2/credentials v1.12.18 // indirect @@ -210,7 +210,7 @@ require ( github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799 // indirect github.com/peterbourgon/diskv v2.0.1+incompatible // indirect - github.com/pkg/errors v0.9.1 // indirect + github.com/pkg/errors v0.9.1 github.com/pluralsh/oauth v0.9.1-0.20220520000222-d76c0e7a0db9 github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_golang v1.12.1 // indirect diff --git a/pkg/api/client.go b/pkg/api/client.go index bb3b9d2e..ad6e09be 100644 --- a/pkg/api/client.go +++ b/pkg/api/client.go @@ -2,8 +2,11 @@ package api import ( "context" + "encoding/json" "net/http" + rawclient "github.com/Yamashou/gqlgenc/client" + "github.com/pkg/errors" "github.com/pluralsh/gqlclient" "github.com/pluralsh/plural/pkg/config" ) @@ -97,3 +100,28 @@ func FromConfig(conf *config.Config) Client { } } + +func GetErrorResponse(err error, methodName string) error { + if err == nil { + return nil + } + errResponse := &rawclient.ErrorResponse{} + newErr := json.Unmarshal([]byte(err.Error()), errResponse) + if newErr != nil { + return err + } + + errList := errors.New(methodName) + if errResponse.GqlErrors != nil { + for _, err := range *errResponse.GqlErrors { + errList = errors.Wrap(errList, err.Message) + } + errList = errors.Wrap(errList, "GraphQL error") + } + if errResponse.NetworkError != nil { + errList = errors.Wrap(errList, errResponse.NetworkError.Message) + errList = errors.Wrap(errList, "Network error") + } + + return errList +} diff --git a/pkg/bundle/installer.go b/pkg/bundle/installer.go index db287275..b8f98558 100644 --- a/pkg/bundle/installer.go +++ b/pkg/bundle/installer.go @@ -14,7 +14,7 @@ import ( func Install(client api.Client, repo, name string, refresh bool) error { recipe, err := client.GetRecipe(repo, name) if err != nil { - return err + return api.GetErrorResponse(err, "GetRecipe") } return doInstall(client, recipe, repo, name, refresh) @@ -79,7 +79,7 @@ func doInstall(client api.Client, recipe *api.Recipe, repo, name string, refresh } if err := client.InstallRecipe(recipe.Id); err != nil { - return fmt.Errorf("Install failed, does your plural user have install permissions? error: %w", err) + return fmt.Errorf("Install failed, does your plural user have install permissions? error: %w", api.GetErrorResponse(err, "InstallRecipe")) } if recipe.OidcSettings == nil { diff --git a/pkg/bundle/oidc.go b/pkg/bundle/oidc.go index 2c52e3b5..b8672e70 100644 --- a/pkg/bundle/oidc.go +++ b/pkg/bundle/oidc.go @@ -33,12 +33,12 @@ func configureOidc(repo string, client api.Client, recipe *api.Recipe, ctx map[s inst, err := client.GetInstallation(repo) if err != nil { - return err + return api.GetErrorResponse(err, "GetInstallation") } me, err := client.Me() if err != nil { - return err + return api.GetErrorResponse(err, "Me") } oidcSettings := &api.OidcProviderAttributes{ @@ -49,8 +49,8 @@ func configureOidc(repo string, client api.Client, recipe *api.Recipe, ctx map[s }, } mergeOidcAttributes(inst, oidcSettings) - - return client.OIDCProvider(inst.Id, oidcSettings) + err = client.OIDCProvider(inst.Id, oidcSettings) + return api.GetErrorResponse(err, "OIDCProvider") } func mergeOidcAttributes(inst *api.Installation, attributes *api.OidcProviderAttributes) { diff --git a/pkg/bundle/stack.go b/pkg/bundle/stack.go index c88edea8..597d4489 100644 --- a/pkg/bundle/stack.go +++ b/pkg/bundle/stack.go @@ -11,7 +11,7 @@ import ( func Stack(client api.Client, name, provider string, refresh bool) error { s, err := client.GetStack(name, provider) if err != nil { - return err + return api.GetErrorResponse(err, "GetStack") } utils.Highlight("You're attempting to install stack: %s\n>> ", s.Name) diff --git a/pkg/crypto/age.go b/pkg/crypto/age.go index d861e9dd..70bcc5ba 100644 --- a/pkg/crypto/age.go +++ b/pkg/crypto/age.go @@ -132,7 +132,7 @@ func SetupAge(client api.Client, emails []string) error { if len(emails) > 0 { keys, err := client.ListKeys(emails) if err != nil { - return err + return api.GetErrorResponse(err, "ListKeys") } missingEmails := findMissingKeyForEmail(emails, keys) @@ -228,7 +228,10 @@ func SetupIdentity(client api.Client, name string) error { return err } - return client.CreateKey(name, userIdentity.Recipient().String()) + if err := client.CreateKey(name, userIdentity.Recipient().String()); err != nil { + return api.GetErrorResponse(err, "CreateKey") + } + return nil } func setupAgeConfig() (*Age, error) { diff --git a/pkg/pluralfile/attrs.go b/pkg/pluralfile/attrs.go index b84a6b3a..f9b8be57 100644 --- a/pkg/pluralfile/attrs.go +++ b/pkg/pluralfile/attrs.go @@ -46,7 +46,8 @@ func (a *RepoAttrs) Push(repo string, sha string) (string, error) { if err != nil { return "", err } - return newsha, client.CreateRepository(repo, a.Publisher, repositoryAttributes) + err = client.CreateRepository(repo, a.Publisher, repositoryAttributes) + return newsha, api.GetErrorResponse(err, "CreateRepository") } func (a *RepoAttrs) mkSha(fullPath string, input *api.RepositoryInput) (sha string, err error) { diff --git a/pkg/pluralfile/lock.go b/pkg/pluralfile/lock.go index 841c9978..c41d6b62 100644 --- a/pkg/pluralfile/lock.go +++ b/pkg/pluralfile/lock.go @@ -67,7 +67,7 @@ func (plrl *Pluralfile) Flush(lock *Lockfile) error { } _, err = client.ReleaseLock(plrl.Repo, string(io)) - return err + return api.GetErrorResponse(err, "ReleaseLock") } func Lock(path string) (*Lockfile, error) { diff --git a/pkg/pluralfile/stack.go b/pkg/pluralfile/stack.go index 79d8aac4..a8b024c8 100644 --- a/pkg/pluralfile/stack.go +++ b/pkg/pluralfile/stack.go @@ -46,5 +46,5 @@ func (a *Stack) Push(repo string, sha string) (string, error) { utils.Success("\u2713\n") } - return newsha, err + return newsha, api.GetErrorResponse(err, "CreateStack") } diff --git a/pkg/pluralfile/tags.go b/pkg/pluralfile/tags.go index f93e1849..6eef8499 100644 --- a/pkg/pluralfile/tags.go +++ b/pkg/pluralfile/tags.go @@ -71,7 +71,7 @@ func (t *Tags) Push(repo string, sha string) (string, error) { } if err := client.UpdateVersion(vspec, tagSpec.Tags); err != nil { fmt.Println("") - return sha, err + return sha, api.GetErrorResponse(err, "UpdateVersion") } utils.Highlight(".") diff --git a/pkg/provider/provider.go b/pkg/provider/provider.go index 824c8fcd..61a76f0b 100644 --- a/pkg/provider/provider.go +++ b/pkg/provider/provider.go @@ -59,7 +59,7 @@ func GetProviderScaffold(provider, version string) (string, error) { scaffold, err := client.GetTfProviderScaffold(provider, version) providers.Scaffolds[provider] = scaffold if err != nil { - return "", err + return "", api.GetErrorResponse(err, "GetTfProviderScaffold") } } return providers.Scaffolds[provider], nil @@ -132,7 +132,7 @@ func getAvailableProviders() error { available[i] = strings.ToLower(available[i]) } if err != nil { - return err + return api.GetErrorResponse(err, "GetTfProviders") } providers.AvailableProviders = available } diff --git a/pkg/scaffold/creator.go b/pkg/scaffold/creator.go index 1daa509f..12d12316 100644 --- a/pkg/scaffold/creator.go +++ b/pkg/scaffold/creator.go @@ -59,7 +59,7 @@ func ApplicationScaffold(client api.Client) error { scaffolds, err := client.Scaffolds(&input) if err != nil { - return err + return api.GetErrorResponse(err, "Scaffolds") } app := input.Application diff --git a/pkg/template/funcs.go b/pkg/template/funcs.go index 8397303b..c965b7cb 100644 --- a/pkg/template/funcs.go +++ b/pkg/template/funcs.go @@ -165,5 +165,9 @@ func toYaml(val interface{}) (string, error) { func eabCredential(cluster, provider string) (*api.EabCredential, error) { client := api.NewClient() - return client.GetEabCredential(cluster, provider) + eabCredential, err := client.GetEabCredential(cluster, provider) + if err != nil { + return nil, api.GetErrorResponse(err, "GetEabCredential") + } + return eabCredential, nil } diff --git a/pkg/wkspace/builder.go b/pkg/wkspace/builder.go index 6a269ff3..5cb48eea 100644 --- a/pkg/wkspace/builder.go +++ b/pkg/wkspace/builder.go @@ -32,7 +32,7 @@ type Workspace struct { func New(client api.Client, inst *api.Installation) (*Workspace, error) { ci, ti, err := client.GetPackageInstallations(inst.Repository.Id) if err != nil { - return nil, err + return nil, api.GetErrorResponse(err, "GetPackageInstallations") } projPath, _ := filepath.Abs("workspace.yaml") diff --git a/pkg/wkspace/graph.go b/pkg/wkspace/graph.go index d57a5828..959c5d38 100644 --- a/pkg/wkspace/graph.go +++ b/pkg/wkspace/graph.go @@ -26,7 +26,7 @@ func TopSort(client api.Client, installations []*api.Installation) ([]*api.Insta ci, tf, err := client.GetPackageInstallations(installation.Repository.Id) if err != nil { - return nil, err + return nil, api.GetErrorResponse(err, "GetPackageInstallations") } deps := algorithms.Map(buildDependencies(repo, ci, tf), func(d *manifest.Dependency) string { return d.Repo }) for _, d := range deps {