Skip to content

Commit

Permalink
fix(errorManagement) do not fail with an exception when the request s…
Browse files Browse the repository at this point in the history
…tatus is not successful (#46)

* Log a warning instead of throwing an exception
* Error should be handled at process level using the `status code`
connector output
  • Loading branch information
rbioteau authored Nov 18, 2020
1 parent 6931d46 commit 081a76d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -522,9 +522,8 @@ public void execute(final Request request) throws Exception {
LOGGER.fine("Response recieved.");
final int statusCode = httpResponse.getStatusLine().getStatusCode();
if (!statusSuccessful(statusCode)) {
throw new ConnectorException(
String.format("%s response status is not successful: %s - %s", request, statusCode,
httpResponse.getStatusLine().getReasonPhrase()));
LOGGER.warning(() -> String.format("%s response status is not successful: %s - %s", request, statusCode,
httpResponse.getStatusLine().getReasonPhrase()));
}
setOutputs(httpResponse, request);
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -919,8 +919,8 @@ public void basicAuthWithUsernamePasswordAndRealm() throws BonitaException {
*/
@Test
public void noServiceAvailable() throws BonitaException {
thrown.expect(ConnectorException.class);
executeConnector(buildMethodParametersSet(GET));
Map<String, Object> output = executeConnector(buildMethodParametersSet(GET));
assertEquals(404, output.get(RESTConnector.STATUS_CODE_OUTPUT_PARAMETER));
}

/**
Expand Down

0 comments on commit 081a76d

Please sign in to comment.