-
Notifications
You must be signed in to change notification settings - Fork 143
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
fix error code #2120
fix error code #2120
Conversation
Signed-off-by: Jing Zhang <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2120 +/- ##
=========================================
Coverage 81.86% 81.87%
Complexity 5644 5644
=========================================
Files 543 543
Lines 22790 22791 +1
Branches 2333 2333
=========================================
+ Hits 18658 18659 +1
Misses 3195 3195
Partials 937 937
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@@ -130,7 +131,8 @@ private void sendResponse(RestChannel channel, MLExecuteTaskResponse response) t | |||
} | |||
|
|||
private void reportError(final RestChannel channel, final Exception e, final RestStatus status) { | |||
channel.sendResponse(new BytesRestResponse(status, ErrorMessageFactory.createErrorMessage(e, status.getStatus()).toString())); | |||
ErrorMessage errorMessage = ErrorMessageFactory.createErrorMessage(e, status.getStatus()); |
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.
Is it possible add a unit test for this?
Signed-off-by: Jing Zhang <[email protected]> (cherry picked from commit a8f983b)
Signed-off-by: Jing Zhang <[email protected]> (cherry picked from commit a8f983b) Co-authored-by: Jing Zhang <[email protected]>
@@ -130,7 +131,8 @@ private void sendResponse(RestChannel channel, MLExecuteTaskResponse response) t | |||
} | |||
|
|||
private void reportError(final RestChannel channel, final Exception e, final RestStatus status) { | |||
channel.sendResponse(new BytesRestResponse(status, ErrorMessageFactory.createErrorMessage(e, status.getStatus()).toString())); | |||
ErrorMessage errorMessage = ErrorMessageFactory.createErrorMessage(e, status.getStatus()); | |||
channel.sendResponse(new BytesRestResponse(RestStatus.fromCode(errorMessage.getStatus()), errorMessage.toString())); |
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.
possible to add header "application/json; charset=UTF-8"
in the response here or convert error to a XContentBuilder instead of errorMessage.toString()
?
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.
Sure, I will send another pr to change it.
Signed-off-by: Jing Zhang <[email protected]>
Signed-off-by: Jing Zhang <[email protected]>
Description
Fix the error code when getting the opensearch exception.
Issues Resolved
[List any issues this PR will resolve]
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.