Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,14 @@ private void delegateToV2Engine(
handleException(restChannel, e);
}
},
this::handleException)
RestSqlAction::handleException)
.accept(channel);
} catch (Exception e) {
handleException(channel, e);
}
}

private void handleException(RestChannel restChannel, Exception exception) {
public static void handleException(RestChannel restChannel, Exception exception) {
RestStatus status = getRestStatus(exception);
logAndPublishMetrics(status, exception);
reportError(restChannel, exception, status);
Expand Down Expand Up @@ -337,12 +337,13 @@ private static boolean isClientError(Exception e) {
|| e instanceof ExpressionEvaluationException;
}

private void sendResponse(
private static void sendResponse(
final RestChannel channel, final String message, final RestStatus status) {
channel.sendResponse(new BytesRestResponse(status, message));
}

private void reportError(final RestChannel channel, final Exception e, final RestStatus status) {
private static void reportError(
final RestChannel channel, final Exception e, final RestStatus status) {
sendResponse(
channel, ErrorMessageFactory.createErrorMessage(e, status.getStatus()).toString(), status);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,7 @@ protected Object buildJsonObject(ExplainResponse resp) {

@Override
public void onFailure(Exception e) {
channel.sendResponse(
new BytesRestResponse(RestSqlAction.getRestStatus(e), e.getMessage()));
RestSqlAction.handleException(channel, e);
}
});
} else {
Expand All @@ -282,8 +281,7 @@ public void onResponse(TransportPPLQueryResponse response) {

@Override
public void onFailure(Exception e) {
channel.sendResponse(
new BytesRestResponse(RestSqlAction.getRestStatus(e), e.getMessage()));
RestSqlAction.handleException(channel, e);
}
});
}
Expand Down
Loading