Skip to content

Commit

Permalink
Send error message as a response when IllegalArgumentException occurs
Browse files Browse the repository at this point in the history
Set the `deviceId` to the error response

closes MusalaSoft/atmosphere-docs#95
closes MusalaSoft/atmosphere-docs#96
  • Loading branch information
dim4o committed Aug 3, 2017
1 parent 19c3a2b commit 71039fb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ dependencies {
compile 'io.github.bonigarcia:webdrivermanager:1.5.0'
compile 'org.seleniumhq.selenium:selenium-java:2.47.1'
compile 'commons-net:commons-net:3.5'
compile 'org.reflections:reflections:0.9.10'
compile 'org.reflections:reflections:0.9.9-RC1'

compile 'org.glassfish.tyrus:tyrus-client:1.13.1'
compile 'org.glassfish.tyrus:tyrus-container-grizzly-client:1.13.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,14 @@ public void run() {
try {
deviceWrapper.route(requestAction, arguments);
} catch (CommandFailedException e) {
sendErrorResponseMessage(e, session, request.getSessionId());
sendErrorResponseMessage(e, session, request);
LOGGER.error(ACTION_FAILD_MESSAGE, e);
}
}
}) {}.start();
}
} catch (CommandFailedException e) {
sendErrorResponseMessage(e, session, request.getSessionId());
} catch (CommandFailedException | IllegalArgumentException e) {
sendErrorResponseMessage(e, session, request);
LOGGER.error(ACTION_FAILD_MESSAGE, e);
}
}
Expand Down Expand Up @@ -217,9 +217,10 @@ public void setDeviceManager(DeviceManager deviceManager) {
this.deviceManager = deviceManager;
}

private void sendErrorResponseMessage(Exception ex, Session session, String requestSessionId) {
private void sendErrorResponseMessage(Exception ex, Session session, RequestMessage request) {
ResponseMessage errorResponse = new ResponseMessage(MessageAction.ERROR, null, null);
errorResponse.setSessionId(requestSessionId);
errorResponse.setSessionId(request.getSessionId());
errorResponse.setDeviceId(request.getDeviceId());
errorResponse.setException(ex);

sendText(jsonUtil.serialize(errorResponse), session);
Expand Down

0 comments on commit 71039fb

Please sign in to comment.