getStatusCode

getStatusCode メソッドは、レスポンス・オブジェクトのステータス・コードを返します。

getStatusCode()

戻り値

レスポンス・オブジェクトは整数を返します。

  • 0 - STATUS_SUCCESS - 呼び出されたメソッドはエラーなく完了しました。アドバイザリー・メッセージはある場合とない場合があります。
  • 1 - STATUS_WARNING - 呼び出されたメソッドは 1 つ以上の警告メッセージを伴って完了しました (エラーはなし)。詳細については、アドバイザリー・メッセージを照会してください。
  • 2 - STATUS_ERROR - 呼び出されたメソッドは正常に完了しませんでした。1 つ以上のエラー・メッセージがあります。詳細については、アドバイザリー・メッセージを照会してください。

以下に、エラー処理で 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());
}