maytasm commented on a change in pull request #11711:
URL: https://github.com/apache/druid/pull/11711#discussion_r713053940
##########
File path: sql/src/main/java/org/apache/druid/sql/http/SqlResource.java
##########
@@ -170,39 +174,50 @@ public Response doPost(
}
catch (QueryCapacityExceededException cap) {
endLifecycle(sqlQueryId, lifecycle, cap, remoteAddr, -1);
- return buildNonOkResponse(QueryCapacityExceededException.STATUS_CODE,
cap);
+ return buildNonOkResponse(
+ QueryCapacityExceededException.STATUS_CODE,
+
serverConfig.getErrorResponseTransformStrategy().transformIfNeeded(cap)
+ );
}
catch (QueryUnsupportedException unsupported) {
endLifecycle(sqlQueryId, lifecycle, unsupported, remoteAddr, -1);
- return buildNonOkResponse(QueryUnsupportedException.STATUS_CODE,
unsupported);
+ return buildNonOkResponse(
+ QueryUnsupportedException.STATUS_CODE,
+
serverConfig.getErrorResponseTransformStrategy().transformIfNeeded(unsupported)
+ );
}
catch (QueryTimeoutException timeout) {
endLifecycle(sqlQueryId, lifecycle, timeout, remoteAddr, -1);
- return buildNonOkResponse(QueryTimeoutException.STATUS_CODE, timeout);
+ return buildNonOkResponse(
+ QueryTimeoutException.STATUS_CODE,
+
serverConfig.getErrorResponseTransformStrategy().transformIfNeeded(timeout)
+ );
}
catch (SqlPlanningException | ResourceLimitExceededException e) {
endLifecycle(sqlQueryId, lifecycle, e, remoteAddr, -1);
- return buildNonOkResponse(BadQueryException.STATUS_CODE, e);
+ return buildNonOkResponse(
+ BadQueryException.STATUS_CODE,
+ serverConfig.getErrorResponseTransformStrategy().transformIfNeeded(e)
+ );
}
catch (ForbiddenException e) {
endLifecycleWithoutEmittingMetrics(sqlQueryId, lifecycle);
- throw e; // let ForbiddenExceptionMapper handle this
+ throw (ForbiddenException)
serverConfig.getErrorResponseTransformStrategy().transformIfNeeded(e); // let
ForbiddenExceptionMapper handle this
}
catch (Exception e) {
log.warn(e, "Failed to handle query: %s", sqlQuery);
endLifecycle(sqlQueryId, lifecycle, e, remoteAddr, -1);
- final Exception exceptionToReport;
+ QueryInterruptedException exceptionToReport;
if (e instanceof RelOptPlanner.CannotPlanException) {
- exceptionToReport = new ISE("Cannot build plan for query: %s",
sqlQuery.getQuery());
+ exceptionToReport = QueryInterruptedException.wrapIfNeeded((new
ISE("Cannot build plan for query: %s", sqlQuery.getQuery())));
Review comment:
Actually now that I look at it...I didn't have to change/refactor those
and can just call
`serverConfig.getErrorResponseTransformStrategy().transformIfNeeded` at the end
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]