I am writing an application that uses RoboSpice. In the request listener onRequestFailure( SpiceException arg0 ) is there a way to know for sure that the error was a result of a 401 HTTP Error occurred?
I have a back end service, that returns a 401 error when a token expires, when that occurs I need to prompt the user to re-enter their credentials.
Is there anyway to know that a 401 HTTP error specifically occurred?
Below is an example of my request.
public class LookupRequest extends SpringAndroidSpiceRequest <Product> {
public String searchText;
public String searchMode;
public LookupRequest() {
super( Product.class );
}
@Override
public Product loadDataFromNetwork() throws Exception {
String url = String.format("%s/Lookup?s=%s&m=%s", Constants.BASE_URL, searchText, searchMode);
Ln.d("Calling URL: %s", url);
return getRestTemplate().getForObject(url, Product.class );
}
equals()
to compare the status code andHttpStatus
. Instead I started comparing them thus without problems:exception.getStatusCode().value() == HttpStatus.SC_BAD_REQUEST
. Hope that helps. – Meddlesome