Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.box.androidsdk.content;
  
Thrown to indicate that an error occurred while communicating with the Box API.
  
  public class BoxException extends Exception {
     private static final long serialVersionUID = 1L;
 
     private final int responseCode;
     private String response;
     private BoxHttpResponse boxHttpResponse;

    
Constructs a BoxAPIException with a specified message.

Parameters:
message a message explaining why the exception occurred.
 
     public BoxException(String message) {
         super(message);
 
         this. = 0;
         this. = null;
         this. = null;
     }

    
Constructs a BoxAPIException with details about the server's response.

Parameters:
message a message explaining why the exception occurred.
response the response body returned by the Box server.
 
     public BoxException(String messageBoxHttpResponse response) {
         super(message, (Throwable)null);
         this. = response;
         if (response != null) {
              = response.getResponseCode();
         } else {
              = 0;
         }
         try {
             this. = response.getStringBody();
         } catch (Exception e){
             this. = null;
         }
     }

    
Constructs a BoxAPIException that wraps another underlying exception.

Parameters:
message a message explaining why the exception occurred.
cause an underlying exception.
 
     public BoxException(String messageThrowable cause) {
         super(messagecause);
 
         this. = 0;
         this. = null;
     }

    
Constructs a BoxAPIException that wraps another underlying exception with details about the server's response.

Parameters:
message a message explaining why the exception occurred.
responseCode the response code returned by the Box server.
response the response body returned by the Box server.
cause an underlying exception.
 
     public BoxException(String messageint responseCodeString responseThrowable cause) {
         super(messagecause);
 
         this. = responseCode;
         this. = response;
     }

    
Gets the response code returned by the server when this exception was thrown.

Returns:
the response code returned by the server.
 
     public int getResponseCode() {
         return this.;
     }

    
Gets the body of the response returned by the server when this exception was thrown.

Returns:
the body of the response returned by the server.
 
     public String getResponse() {
         return this.;
     }


    
Gets the server response as a BoxError.

Returns:
the response as a BoxError, or null if the response cannot be converted.
 
     public BoxError getAsBoxError(){
         try{
             BoxError error = new BoxError();
             error.createFromJson(getResponse());
             return error;
        } catch (Exception e){
            return null;
        }
    }


    
An exception that indicates the RealTimeServerConnection has exceeded the recommended number of retries.
    public static class MaxAttemptsExceeded extends BoxException {
        private final int mTimesTried;

        

Parameters:
message message for this exception.
timesTried number of times tried before failing.
        public MaxAttemptsExceeded(String messageint timesTried) {
            this(messagetimesTriednull);
        }
        public MaxAttemptsExceeded(String messageint timesTriedBoxHttpResponse response) {
            super(message + timesTriedresponse);
             = timesTried;
        }

        

Returns:
the number of times tried specified from constructor.
        public int getTimesTried() {
            return ;
        }
    }
    public static class RateLimitAttemptsExceeded extends MaxAttemptsExceeded {
        public RateLimitAttemptsExceeded(String messageint timesTriedBoxHttpResponse response) {
            super(messagetimesTriedresponse);
        }
    }
New to GrepCode? Check out our FAQ X