vvysotskyi commented on a change in pull request #2194:
URL: https://github.com/apache/drill/pull/2194#discussion_r604409604
##########
File path:
exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/stream/StreamingHttpConnection.java
##########
@@ -219,12 +230,39 @@ private void emitRows(RowSetReader batchReader) throws
IOException {
*/
public void finish() throws IOException {
JsonOutput gen = writer.jsonOutput();
- gen.writeEndArray();
- writeNewline(gen);
+ if (batchCount == 0) {
+ startHeader();
+ if (options != null &&
+
Boolean.parseBoolean(options.get(ExecConstants.ENABLE_VERBOSE_ERRORS_KEY))) {
+ emitErrorInfo();
+ }
+ } else {
+ gen.writeEndArray();
+ writeNewline(gen);
+ }
gen.writeFieldName("queryState");
gen.writeVarChar(getQueryState());
writeNewline(gen);
gen.writeEndObject();
writeNewline(gen);
}
+
+ private void emitErrorInfo() throws IOException {
+ JsonOutput gen = writer.jsonOutput();
+ Throwable exception =
DrillExceptionUtil.getThrowable(error.getException());
+ if (exception != null) {
+ gen.writeFieldName("exception");
+ gen.writeVarChar(exception.getClass().getName());
+ writeNewline(gen);
+ gen.writeFieldName("errorMessage");
+ gen.writeVarChar(exception.getMessage());
+ writeNewline(gen);
+ gen.writeFieldName("stackTrace");
Review comment:
Good point, thanks, updated the code to pass stack trace items as a list
and updated the PR description with the example of how it will look like.
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]