-
Notifications
You must be signed in to change notification settings - Fork 105
Align NodePool frontend CRUD to cluster CRUD on internal types #3460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,7 +20,11 @@ import ( | |
| "fmt" | ||
| "net/http" | ||
|
|
||
| ocmerrors "github.com/openshift-online/ocm-sdk-go/errors" | ||
|
|
||
| "github.com/Azure/ARO-HCP/internal/api/arm" | ||
| "github.com/Azure/ARO-HCP/internal/database" | ||
| "github.com/Azure/ARO-HCP/internal/ocm" | ||
| ) | ||
|
|
||
| // erroringHTTPHandler is an http handler that leaves error reporting to a higher layer | ||
|
|
@@ -53,6 +57,13 @@ func writeError(ctx context.Context, w http.ResponseWriter, err error, args ...i | |
|
|
||
| logger.Error(fmt.Sprintf("%v", err), args...) // fmt used to handle nil | ||
|
|
||
| var ocmError *ocmerrors.Error | ||
| if errors.As(err, &ocmError) { | ||
| resourceID, _ := ResourceIDFromContext(ctx) // used for error reporting | ||
| arm.WriteCloudError(w, ocm.CSErrorToCloudError(err, resourceID, w.Header())) | ||
| return nil | ||
| } | ||
|
|
||
| var cloudErr *arm.CloudError | ||
| if err != nil && errors.As(err, &cloudErr) { | ||
| if cloudErr != nil { // difference between interface is nil and the content is nil | ||
|
|
@@ -61,6 +72,16 @@ func writeError(ctx context.Context, w http.ResponseWriter, err error, args ...i | |
| } | ||
| } | ||
|
|
||
| if database.IsResponseError(err, http.StatusNotFound) { | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. convenient for error handling simplification. |
||
| resourceID, err := ResourceIDFromContext(ctx) // used for error reporting | ||
| if err != nil { | ||
| arm.WriteInternalServerError(w) | ||
| return nil | ||
| } | ||
|
Comment on lines
+77
to
+80
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same concern as above except |
||
| arm.WriteCloudError(w, arm.NewResourceNotFoundError(resourceID)) | ||
| return nil | ||
| } | ||
|
|
||
| arm.WriteInternalServerError(w) | ||
| return nil | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
convenient for error handling when we're able to do this.