Skip to content

Commit

Permalink
Adding in a defensive check
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsully83 committed Mar 6, 2024
1 parent 7bbf6a1 commit 3ff69f4
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.commons.lang3.StringUtils;

public class AuthorizationCodeException extends RestApiException {

private static final Pattern GET_DETAIL_ERROR = Pattern.compile(".*?<p class=\"error\">(.*?)</p>", Pattern.DOTALL);
Expand All @@ -20,6 +22,10 @@ public AuthorizationCodeException(String message, Throwable cause) {
}

private static String parseErrorMessageFromHtml(String responseBody) {
if (StringUtils.isBlank(responseBody)) {
return "";
}

Matcher matcher = GET_DETAIL_ERROR.matcher(responseBody);

if (matcher.find()) {
Expand Down

0 comments on commit 3ff69f4

Please sign in to comment.