Coverage Report - org.codeforamerica.open311.facade.exceptions.APIWrapperException
 
Classes in this File Line Coverage Branch Coverage Complexity
APIWrapperException
75%
9/12
50%
1/2
1.143
APIWrapperException$Error
100%
10/10
N/A
1.143
 
 1  
 package org.codeforamerica.open311.facade.exceptions;
 2  
 
 3  
 import org.codeforamerica.open311.facade.APIWrapper;
 4  
 
 5  
 /**
 6  
  * Thrown if it was any problem performing an operation through the
 7  
  * {@link APIWrapper}.
 8  
  * 
 9  
  * @author Santiago MunĂ­n <santimunin@gmail.com>
 10  
  * 
 11  
  */
 12  
 public class APIWrapperException extends Exception {
 13  
 
 14  
         private static final long serialVersionUID = 1L;
 15  
         private Error error;
 16  
         private GeoReportV2Error geoReportError;
 17  
 
 18  
         public APIWrapperException(String message, Error error,
 19  
                         GeoReportV2Error geoReportError) {
 20  4
                 super(message);
 21  4
                 this.error = error;
 22  4
                 this.geoReportError = geoReportError;
 23  4
         }
 24  
 
 25  
         public static long getSerialversionuid() {
 26  0
                 return serialVersionUID;
 27  
         }
 28  
 
 29  
         public Error getError() {
 30  0
                 return error;
 31  
         }
 32  
 
 33  
         public GeoReportV2Error getGeoReportError() {
 34  1
                 return geoReportError;
 35  
         }
 36  
 
 37  
         public String toString() {
 38  1
                 String result = this.getMessage() + " (" + this.error;
 39  1
                 if (geoReportError != null) {
 40  0
                         result += " -- " + geoReportError.toString();
 41  
                 }
 42  1
                 result += ")";
 43  1
                 return result;
 44  
         }
 45  
 
 46  
         /**
 47  
          * Different types of errors.
 48  
          */
 49  1
         public static enum Error {
 50  1
                 DATA_PARSING("Problem while parsing text data."), NETWORK_MANAGER(
 51  1
                                 "Network problem."), URL_BUILDER(
 52  1
                                 "Problem while building a valid URL."), GEO_REPORT_V2(
 53  1
                                 "GeoReport v2 problem."), NOT_SUITABLE_ENDPOINT_FOUND(
 54  1
                                 "Problem finding a suitable endpoint."), NOT_CREATED_BY_A_WRAPPER(
 55  
                                 "The given object wasn't created by any wrapper");
 56  
                 private String description;
 57  
 
 58  6
                 private Error(String description) {
 59  6
                         this.description = description;
 60  6
                 }
 61  
 
 62  
                 public String toString() {
 63  1
                         return this.description;
 64  
                 }
 65  
         }
 66  
 
 67  
 }