Skip to content

Commit

Permalink
More logging during unexpected error in ipc protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
dzmipt committed Oct 18, 2024
1 parent 15f1a9c commit e4a6cef
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
9 changes: 8 additions & 1 deletion src/kx/KConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public void run() {
} catch (Throwable e) {
synchronized (lockRead) {
IOException io = e instanceof IOException ?
(IOException) e : new IOException("Exception in message deserialization", e);
(IOException) e : new InternalProtocolError("Exception in message deserialization", e);
message = new KMessage(io);
message.setFinished(K.KTimestamp.now());
lockRead.notifyAll();
Expand All @@ -266,4 +266,11 @@ public void run() {
}
}
}

public static class InternalProtocolError extends IOException {
public InternalProtocolError(String message, Throwable cause) {
super(message, cause);
}
}

}
13 changes: 9 additions & 4 deletions src/studio/ui/action/QueryExecutor.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package studio.ui.action;

import kx.K4Exception;
import kx.KConnection;
import kx.KMessage;
import kx.ProgressCallback;
import org.apache.logging.log4j.LogManager;
Expand Down Expand Up @@ -135,11 +136,15 @@ protected QueryResult doInBackground() {
}
result.setError(e);
}
if (result.getError() != null) {
if (result.getError() instanceof K4Exception) {
queryLog.info("#{}: server returns error {}", queryIndex, result.getError().getMessage());
Throwable error = result.getError();
if (error != null) {
if (error instanceof K4Exception) {
queryLog.info("#{}: server returns error {}", queryIndex, error.getMessage());
} else {
queryLog.info("#{}: error during execution {} {}", queryIndex, result.getError().getClass().getName(), result.getError().getMessage());
queryLog.info("#{}: error during execution {} {}", queryIndex, error.getClass().getName(), error.getMessage());
if (error instanceof KConnection.InternalProtocolError) {
log.error("Unexpected error during query execution", error);
}
}
} else {
if (queryTask.returnResult()) {
Expand Down

0 comments on commit e4a6cef

Please sign in to comment.