Skip to content

Commit

Permalink
Reorder V1 and V2 error messages.
Browse files Browse the repository at this point in the history
Signed-off-by: Yury-Fridlyand <yuryf@bitquilltech.com>
  • Loading branch information
Yury-Fridlyand committed Sep 10, 2022
1 parent 4317e68 commit 98df515
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion docs/user/admin/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ SQL query::
{
"error": {
"reason": "Invalid SQL query",
"details": "DELETE clause is disabled by default and will be deprecated. Using the plugins.sql.delete.enabled setting to enable it\nQuery failed on both V1 and V2 SQL parser engines. V2 SQL parser error following: \nFailed to parse query due to offending symbol [DELETE] at: 'DELETE' <--- HERE... More details: Expecting tokens in {<EOF>, 'DESCRIBE', 'SELECT', 'SHOW', ';'}",
"details": "Failed to parse query due to offending symbol [DELETE] at: 'DELETE' <--- HERE... More details: Expecting tokens in {<EOF>, 'DESCRIBE', 'SELECT', 'SHOW', ';'}\nQuery failed on both V1 and V2 SQL engines. V1 SQL engine error following: \nDELETE clause is disabled by default and will be deprecated. Using the plugins.sql.delete.enabled setting to enable it",
"type": "SQLFeatureDisabledException"
},
"status": 400
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,12 @@ public void sqlDeleteSettingsTest() throws IOException {
"{\n"
+ " \"error\": {\n"
+ " \"reason\": \"Invalid SQL query\",\n"
+ " \"details\": \"DELETE clause is disabled by default and will be deprecated."
+ " Using the plugins.sql.delete.enabled setting to enable it\\nQuery failed "
+ "on both V1 and V2 SQL parser engines. V2 SQL parser error following: \\n"
+ " \"details\": \""
+ "Query request is not supported. Either unsupported fields are present, the "
+ "request is not a cursor request, or the response format is not supported.\",\n"
+ "request is not a cursor request, or the response format is not supported.\\n"
+ "Query failed on both V1 and V2 SQL engines. V1 SQL engine error following: \\n"
+ "DELETE clause is disabled by default and will be deprecated."
+ " Using the plugins.sql.delete.enabled setting to enable it\",\n"
+ " \"type\": \"SQLFeatureDisabledException\"\n"
+ " },\n"
+ " \"status\": 400\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

package org.opensearch.sql.legacy.executor.format;

import lombok.Setter;
import org.json.JSONObject;
import org.opensearch.rest.RestStatus;

Expand All @@ -16,16 +17,13 @@ public class ErrorMessage<E extends Exception> {
private int status;
private String type;
private String reason;
@Setter
private String details;

public String getDetails() {
return details;
}

public void addDetails(String moreDetails) {
details += moreDetails;
}

public ErrorMessage(E exception, int status) {
this.exception = exception;
this.status = status;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,9 @@ private void sendResponse(final RestChannel channel, final String message, final
private void reportError(final RestChannel channel, final Exception e, final RestStatus status) {
var message = ErrorMessageFactory.createErrorMessage(e, status.getStatus());
if (null != QueryContext.getError()) {
message.addDetails(
"\nQuery failed on both V1 and V2 SQL parser engines. V2 SQL parser error following: \n"
+ QueryContext.getError());
message.setDetails(QueryContext.getError() +
"\nQuery failed on both V1 and V2 SQL engines. V1 SQL engine error following: \n"
+ message.getDetails());
}
sendResponse(channel, message.toString(), status);
}
Expand Down

0 comments on commit 98df515

Please sign in to comment.