Explorar o código

case for 422 when enabling a PR for preview env

Mohammed Nafees %!s(int64=4) %!d(string=hai) anos
pai
achega
976a86866b
Modificáronse 1 ficheiros con 11 adicións e 2 borrados
  1. 11 2
      api/server/handlers/environment/enable_pull_request.go

+ 11 - 2
api/server/handlers/environment/enable_pull_request.go

@@ -78,11 +78,20 @@ func (c *EnablePullRequestHandler) ServeHTTP(w http.ResponseWriter, r *http.Requ
 
 	if ghResp != nil {
 		if ghResp.StatusCode == 404 {
-			c.HandleAPIError(w, r, apierrors.NewErrPassThroughToClient(fmt.Errorf("workflow file not found"), 404))
+			c.HandleAPIError(w, r, apierrors.NewErrPassThroughToClient(
+				fmt.Errorf(
+					"Please make sure the preview environment workflow files are present in PR branch %s and are up to"+
+						" date with the default branch", request.BranchFrom,
+				), 404),
+			)
 			return
 		} else if ghResp.StatusCode == 422 {
 			c.HandleAPIError(w, r, apierrors.NewErrPassThroughToClient(
-				fmt.Errorf("please make sure the workflow file in branch %s is up to date", request.BranchFrom), 422))
+				fmt.Errorf(
+					"Please make sure the workflow files in PR branch %s are up to date with the default branch",
+					request.BranchFrom,
+				), 422),
+			)
 			return
 		}
 	}