getStatusCode
getStatusCode()
The
getStatusCode
method returns the status code of a Response object.
Return value
The Response object returns an integer.
0 - STATUS_SUCCESS - The method called completed with no errors. There may or may not be Advisory Messages.
1 - STATUS_WARNING - The method called completed with at least one warning message (but no errors). Query Advisory Messages for more details.
2 - STATUS_ERROR - The method called did not complete successfully and has at least one error message. Query Advisory Messages for more details.
Example
The following is an example of how you can use
getStatusCode
in error handling.
public static void processSetDebugResponse(Response response)
{
// check if response is successful or not
if(response.getStatusCode() == Response.STATUS_SUCCESS)
{
System.out.println("setDebug call processed with no warnings or errors");
}
else if(response.getStatusCode() == Response.STATUS_WARNING)
{
System.out.println("setDebug call processed with a warning");
}
else
{
System.out.println("setDebug call processed with an error");
}
// For any non-successes, there should be advisory messages explaining why
if(response.getStatusCode() != Response.STATUS_SUCCESS)
printDetailMessageOfWarningOrError("setDebug",
response.getAdvisoryMessages());
}
Copyright IBM Corporation 2013. All Rights Reserved.