title: How to detect 404 response code from IO exception?
body: <p>How are you suppose to detect a 404 from an IO exception. I could just search the error message for "404", but is that the correct way?   Anything more direct?</p>
  
  <pre><code>  import com.google.api.services.drive.model.File;
    import com.google.api.services.drive.Drive.Files.Update;
    import com.google.api.services.drive.Drive;
  
  
      File result = null;
  
      try {
  
          update = drive.files().update(driveId, file , mediaContent);
          update.setNewRevision(true);
  
          result = update.execute();
  
      } catch (IOException e) {
  
          Log.e(TAG, "file update exception, statusCode: " + update.getLastStatusCode());
          Log.e(TAG, "file update exception, e: " + e.getMessage());
  
      }   
  
  Log.e(TAG, "file update exception, statuscode " + update.getLastStatusCode());
  
  03-03 05:04:31.738: E/System.out(31733): file update exception, statusCode: -1
  03-03 05:04:31.738: E/System.out(31733): file update exception, e: 404 Not Found
  03-03 05:04:31.738: E/System.out(31733): "message": "File not found: FileIdRemoved",
  </code></pre>
  
  <p>Answer:  Aegan's comment below was correct, turns out you can subclass the the exception to a GoogleJsonResponseException and from there get the status code.   The answer in this case ultimately depended on the fact I am using a GoogleClient, which generates a subclass of IO Exception that contains the status code.</p>
  
  <p>Example:</p>
  
  <pre><code>Try{
      ...
      }catch (IOException e) {
  
        if(e instanceof GoogleJsonResponseException){
            int statusCode = ((GoogleJsonResponseException) e).getStatusCode();
            //do something
     }
   }
  </code></pre>