Skip to content
Snippets Groups Projects

Iss #109 - Add full 5xx series HTTP error coverage when fetching profile

Merged Iss #109 - Add full 5xx series HTTP error coverage when fetching profile
2 unresolved threads
Merged Martin Lowe requested to merge malowe/main/109 into main
2 unresolved threads
5 files
+ 88
3
Compare changes
  • Side-by-side
  • Inline
Files
5
@@ -43,7 +43,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
@@ -43,7 +43,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.ws.rs.WebApplicationException;
import jakarta.ws.rs.WebApplicationException;
import jakarta.ws.rs.core.Response.Status;
/**
/**
* Helper class used to fetch from various sources for profile data
* Helper class used to fetch from various sources for profile data
@@ -88,7 +87,8 @@ public class ProfileHelper {
@@ -88,7 +87,8 @@ public class ProfileHelper {
return Optional.of(accountsAPI.getAccountsProfileByUsername(username, getBearerToken()));
return Optional.of(accountsAPI.getAccountsProfileByUsername(username, getBearerToken()));
} catch (WebApplicationException e) {
} catch (WebApplicationException e) {
int status = e.getResponse().getStatus();
int status = e.getResponse().getStatus();
if (status == Status.INTERNAL_SERVER_ERROR.getStatusCode()) {
// Iss #109 - We should throw a 500 an any 5xx error code rather than just for 500
 
if (status / 100 == 5) {
throw new ApplicationException(ERROR_MSG);
throw new ApplicationException(ERROR_MSG);
}
}
@@ -117,7 +117,7 @@ public class ProfileHelper {
@@ -117,7 +117,7 @@ public class ProfileHelper {
return Optional.of(accountsAPI.getAccountsProfileByUid(uid, getBearerToken()).get(0));
return Optional.of(accountsAPI.getAccountsProfileByUid(uid, getBearerToken()).get(0));
} catch (WebApplicationException e) {
} catch (WebApplicationException e) {
int status = e.getResponse().getStatus();
int status = e.getResponse().getStatus();
if (status == Status.INTERNAL_SERVER_ERROR.getStatusCode()) {
if (status / 100 == 5) {
throw new ApplicationException(ERROR_MSG);
throw new ApplicationException(ERROR_MSG);
}
}
Loading