Coverage Report - net.sf.snmpadaptor4j.api.SnmpException
 
Classes in this File Line Coverage Branch Coverage Complexity
SnmpException
100 %
14/14
100 %
4/4
1,333
 
 1  
 package net.sf.snmpadaptor4j.api;
 2  
 
 3  
 import org.apache.log4j.Level;
 4  
 
 5  
 /**
 6  
  * SNMP exception.
 7  
  * @author <a href="http://fr.linkedin.com/in/jpminetti/">Jean-Philippe MINETTI</a>
 8  
  */
 9  
 public final class SnmpException
 10  
                 extends RuntimeException {
 11  
 
 12  
         /**
 13  
          * Serial number.
 14  
          */
 15  
         private static final long serialVersionUID = -5077386573357989009L;
 16  
 
 17  
         /**
 18  
          * Error status.
 19  
          */
 20  
         private final int errorStatus;
 21  
 
 22  
         /**
 23  
          * Logger level.
 24  
          */
 25  
         private final Level loggerLevel;
 26  
 
 27  
         /**
 28  
          * Constructor.
 29  
          * @param errorStatus Error status.
 30  
          */
 31  
         public SnmpException (final int errorStatus) {
 32  4
                 this(null, errorStatus, (Level) null);
 33  4
         }
 34  
 
 35  
         /**
 36  
          * Constructor.
 37  
          * @param message Detailed message on error.
 38  
          * @param errorStatus Error status.
 39  
          * @param cause Error cause.
 40  
          */
 41  
         public SnmpException (final String message, final int errorStatus, final Throwable cause) {
 42  2
                 super("error " + errorStatus + " (" + message + ")", cause);
 43  2
                 this.errorStatus = errorStatus;
 44  2
                 this.loggerLevel = Level.ERROR;
 45  2
         }
 46  
 
 47  
         /**
 48  
          * Constructor.
 49  
          * @param message Detailed message on error.
 50  
          * @param errorStatus Error status.
 51  
          */
 52  
         public SnmpException (final String message, final int errorStatus) {
 53  281
                 this(message, errorStatus, (Level) null);
 54  281
         }
 55  
 
 56  
         /**
 57  
          * Constructor.
 58  
          * @param message Detailed message on error.
 59  
          * @param errorStatus Error status.
 60  
          * @param loggerLevel Logger level.
 61  
          */
 62  
         public SnmpException (final String message, final int errorStatus, final Level loggerLevel) {
 63  288
                 super("error " + errorStatus + (message != null ? " (" + message + ")" : ""));
 64  288
                 this.errorStatus = errorStatus;
 65  288
                 this.loggerLevel = (loggerLevel != null ? loggerLevel : Level.ERROR);
 66  288
         }
 67  
 
 68  
         /**
 69  
          * Returns the error status.
 70  
          * @return Error status.
 71  
          */
 72  
         public int getErrorStatus () {
 73  290
                 return this.errorStatus;
 74  
         }
 75  
 
 76  
         /**
 77  
          * Returns the logger level.
 78  
          * @return Logger level.
 79  
          */
 80  
         public Level getLoggerLevel () {
 81  290
                 return this.loggerLevel;
 82  
         }
 83  
 
 84  
 }