Skip to content

Commit

Permalink
ResultType.EXCEPTION and ResultType.ERROR are handled the exact same …
Browse files Browse the repository at this point in the history
…way,

so remove one of them and simplify some code.
  • Loading branch information
jleyba committed Dec 31, 2013
1 parent 0b5c69e commit 2118dff
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ private void setUpMappings(DriverSessions driverSessions, Logger logger) {

Result jsonErrorResult = new Result(MimeType.EMPTY,
new JsonErrorExceptionResult(EXCEPTION, RESPONSE));
addGlobalHandler(ResultType.EXCEPTION, jsonErrorResult);
addGlobalHandler(ResultType.ERROR, jsonErrorResult);

Result xdrpcResult = new Result(MimeType.CROSS_DOMAIN_RPC,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public void handle(String pathInfo, final HttpRequest request,
} catch (SessionNotFoundException e){
throw e;
} catch (Exception e) {
result = ResultType.EXCEPTION;
result = ResultType.ERROR;
log.log(Level.WARNING, "Exception thrown", e);

Throwable toUse = getRootExceptionCause(e);
Expand All @@ -228,7 +228,7 @@ public void handle(String pathInfo, final HttpRequest request,
}
} catch (Error e) {
log.info("Error: " + e.getMessage());
result = ResultType.EXCEPTION;
result = ResultType.ERROR;
request.setAttribute("exception", e);
}

Expand All @@ -248,7 +248,7 @@ public void handle(String pathInfo, final HttpRequest request,

private void replyError(HttpRequest request, final HttpResponse response, Exception e)
throws Exception {
Renderer renderer2 = getRenderer(ResultType.EXCEPTION, request);
Renderer renderer2 = getRenderer(ResultType.ERROR, request);
request.setAttribute("exception", e);
renderer2.render(request, response, null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
package org.openqa.selenium.remote.server.rest;

public enum ResultType {

SUCCESS,
ERROR,
EXCEPTION,
ERROR
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public void testFailsWhenUnableToDetermineResultTypeForRequest_noHandlersRegiste
final HttpRequest mockRequest = mock(HttpRequest.class);

try {
config.getRenderer(ResultType.EXCEPTION, mockRequest);
config.getRenderer(ResultType.ERROR, mockRequest);
fail("Should have thrown a NPE");
} catch (NullPointerException expected) {
}
Expand Down

0 comments on commit 2118dff

Please sign in to comment.