getStatusCode
getStatusCode()
getStatusCode
方法返回 Response 对象的状态码。
返回值
Response 对象返回一个整数。
0 - STATUS_SUCCESS - 调用的方法已完成,没有任何错误。可能有也可能没有咨询消息。
1 - STATUS_WARNING - 调用的方法已完成,且至少有一个警告消息(但没有错误)。请查询咨询消息以获取更多详细信息。
2 - STATUS_ERROR - 调用的方法未成功完成,并且至少有一个错误消息。请查询咨询消息以获取更多详细信息。
示例
以下是您能够如何在错误处理中使用
getStatusCode
的示例。
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 2012. All Rights Reserved.