-
Notifications
You must be signed in to change notification settings - Fork 42
chore: Fix error code mapping #1571
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,11 +22,16 @@ import ( | |
| ) | ||
|
|
||
| func getHandlerErrorCode(response *http.Response) string { | ||
| if response == nil { | ||
| return string(types.HandlerErrorCodeInternalFailure) | ||
| } | ||
| switch response.StatusCode { | ||
| case http.StatusBadRequest: | ||
| return string(types.HandlerErrorCodeInvalidRequest) | ||
| case http.StatusNotFound: | ||
| return string(types.HandlerErrorCodeNotFound) | ||
| case http.StatusConflict: | ||
|
Member
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. moved logic from GetFailedEventByResponse for StatusConflict |
||
| return string(types.HandlerErrorCodeAlreadyExists) | ||
| case http.StatusInternalServerError: | ||
| return string(types.HandlerErrorCodeServiceInternalError) | ||
| case http.StatusPaymentRequired, http.StatusUnauthorized: | ||
|
|
@@ -37,34 +42,6 @@ func getHandlerErrorCode(response *http.Response) string { | |
| } | ||
|
|
||
| func GetFailedEventByResponse(message string, response *http.Response) handler.ProgressEvent { | ||
| if response == nil { | ||
| return handler.ProgressEvent{ | ||
| OperationStatus: handler.Failed, | ||
| Message: message, | ||
| HandlerErrorCode: string(types.HandlerErrorCodeHandlerInternalFailure)} | ||
| } | ||
|
|
||
| if response.StatusCode == http.StatusConflict { | ||
| return handler.ProgressEvent{ | ||
| OperationStatus: handler.Failed, | ||
| Message: message, | ||
| HandlerErrorCode: string(types.HandlerErrorCodeAlreadyExists)} | ||
| } | ||
|
|
||
| if response.StatusCode == http.StatusUnauthorized { | ||
| return handler.ProgressEvent{ | ||
|
Member
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. wrong mapping, and already handled in getHandlerErrorCode |
||
| OperationStatus: handler.Failed, | ||
| Message: "Not found", | ||
| HandlerErrorCode: string(types.HandlerErrorCodeNotFound)} | ||
| } | ||
|
|
||
| if response.StatusCode == http.StatusBadRequest { | ||
| return handler.ProgressEvent{ | ||
| OperationStatus: handler.Failed, | ||
| Message: message, | ||
| HandlerErrorCode: string(types.HandlerErrorCodeNotFound)} | ||
|
Member
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. wrong mapping, and already handled in getHandlerErrorCode |
||
| } | ||
|
|
||
| return handler.ProgressEvent{ | ||
| OperationStatus: handler.Failed, | ||
| Message: message, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
redundant as it's already done in GetFailedEventByResponse at the beginning of the func