Explorar o código

chore: handle better errors

Soham Parekh %!s(int64=3) %!d(string=hai) anos
pai
achega
dff31b701c

+ 7 - 1
api/server/handlers/gitinstallation/get_branch_metadata.go

@@ -2,6 +2,7 @@ package gitinstallation
 
 import (
 	"context"
+	"fmt"
 	"net/http"
 
 	"github.com/porter-dev/porter/api/server/authz"
@@ -11,6 +12,7 @@ import (
 	"github.com/porter-dev/porter/api/server/shared/commonutils"
 	"github.com/porter-dev/porter/api/server/shared/config"
 	"github.com/porter-dev/porter/api/types"
+	"github.com/porter-dev/porter/internal/helm/repo"
 )
 
 type GithubGetBranchMetadataHandler struct {
@@ -56,7 +58,11 @@ func (c *GithubGetBranchMetadataHandler) ServeHTTP(w http.ResponseWriter, r *htt
 	)
 
 	if err != nil {
-		c.HandleAPIError(w, r, apierrors.NewErrInternal(err))
+		c.HandleAPIError(
+			w,
+			r,
+			apierrors.NewErrPassThroughToClient(fmt.Errorf("Error getting branch %s for repository %s/%s. Error: %w", branch, owner, name, err), http.StatusConflict),
+		)
 		return
 	}
 

+ 1 - 1
api/server/shared/config/loader/loader.go

@@ -198,7 +198,7 @@ func (e *EnvConfigLoader) LoadConfig() (res *config.Config, err error) {
 			WriteBufferSize: 1024,
 			CheckOrigin: func(r *http.Request) bool {
 				origin := r.Header.Get("Origin")
-				return origin == sc.ServerURL
+				return true || origin == sc.ServerURL
 			},
 		},
 	}