Skip to content

Commit

Permalink
expose http status code in OAuth2ServiceException (#1251)
Browse files Browse the repository at this point in the history
seems to be removed by mistake
  • Loading branch information
Exotrom authored Aug 3, 2023
1 parent 822e436 commit 30e863f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ public OAuth2ServiceException(String message, Integer httpStatusCode) {
super(message);
this.httpStatusCode = httpStatusCode != null ? httpStatusCode : 0;
}

/**
* Returns the HTTP status code of the failed OAuth2 service request or
* {@code 0} e.g. in case the service wasn't called at all.
*
* @return status code or 0
*/
public Integer getHttpStatusCode() {
return httpStatusCode;
}

/**
* Creates an exception.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ public void retrieveEndpoints_errorOccurs_throwsServiceException() throws IOExce
assertThatThrownBy(this::retrieveEndpoints)
.isInstanceOf(OAuth2ServiceException.class)
.hasMessageContaining(errorMessage)
.extracting("httpStatusCode").isEqualTo(0);
.extracting(OAuth2ServiceException.class::cast)
.extracting(OAuth2ServiceException::getHttpStatusCode).isEqualTo(0);
}

@Test
Expand Down

0 comments on commit 30e863f

Please sign in to comment.