Coverage report

  %line %branch
nl.toolforge.karma.core.vc.cvsimpl.CVSRuntimeException
58% 
100% 

 1  
 /*
 2  
 Karma core - Core of the Karma application
 3  
 Copyright (C) 2004  Toolforge <www.toolforge.nl>
 4  
 
 5  
 This library is free software; you can redistribute it and/or
 6  
 modify it under the terms of the GNU Lesser General Public
 7  
 License as published by the Free Software Foundation; either
 8  
 version 2.1 of the License, or (at your option) any later version.
 9  
 
 10  
 This library is distributed in the hope that it will be useful,
 11  
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 13  
 Lesser General Public License for more details.
 14  
 
 15  
 You should have received a copy of the GNU Lesser General Public
 16  
 License along with this library; if not, write to the Free Software
 17  
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 18  
 */
 19  
 package nl.toolforge.karma.core.vc.cvsimpl;
 20  
 
 21  
 import nl.toolforge.karma.core.ErrorCode;
 22  
 
 23  
 /**
 24  
  * <p>This exception is thrown by the {@link CVSResponseAdapter} when an error message was received from CVS. The listener
 25  
  * mechanism that is used by the Netbeans API sends events to a listener. Succesfull commands to CVS are passed to a
 26  
  * {@link nl.toolforge.karma.core.cmd.CommandResponseHandler}, handled by Karma, but we want to be able to throw
 27  
  * exceptions when errors have occurred. With a <code>RuntimeException</code>, we have the means to do so.
 28  
  *
 29  
  * <p>There is a little trick required to get to fetch this exception. The Netbeans API fetches all
 30  
  * <code>RuntimeException</code>s and re-throws it as a <code>org.netbeans.lib.cvsclient.command.CommandException</code>.
 31  
  * The original (runtime-)exception is kept in its <code>getUnderlyingException()</code>-method, which is thus used
 32  
  * to determine if we threw a <code>CVSRuntimeException</code>. Works fine ...
 33  
  *
 34  
  * @author D.A. Smedes
 35  
  * @version $Id: CVSRuntimeException.java,v 1.4 2004/11/02 22:26:44 asmedes Exp $
 36  
  */
 37  
 final class CVSRuntimeException extends RuntimeException {
 38  
 
 39  96
   private ErrorCode errorCode = null;
 40  96
   private Object[] messageArguments = null;
 41  110
 
 42  110
   /**
 43  
    * Constructs a <code>CVSRuntimeException</code>, with a non-<code>null</code> <code>ErrorCode</code>.
 44  
    *
 45  
    * @param errorCode An <code>ErrorCode</code> instance. Should not be <code>null</code> (or an
 46  
    *                  <code>IllegalArgumentException</code> will be thrown.
 47  
    */
 48  
   public CVSRuntimeException(ErrorCode errorCode) {
 49  0
     this(errorCode, null);
 50  0
   }
 51  
 
 52  
   public CVSRuntimeException(Throwable t, ErrorCode errorCode) {
 53  0
     super(t);
 54  0
     this.errorCode = errorCode;
 55  0
   }
 56  
 
 57  96
   public CVSRuntimeException(ErrorCode errorCode, Object[] messageArguments) {
 58  96
     this.errorCode = errorCode;
 59  206
     this.messageArguments = messageArguments;
 60  206
   }
 61  110
 
 62  110
   public CVSRuntimeException(Throwable t, ErrorCode errorCode, Object[] messageArguments) {
 63  0
     super(t);
 64  0
     this.errorCode = errorCode;
 65  0
     this.messageArguments = messageArguments;
 66  0
   }
 67  
 
 68  
 
 69  
   public String getMessage() {
 70  192
     if (messageArguments != null && messageArguments.length > 0) {
 71  32
       errorCode.setMessageArguments(messageArguments);
 72  121
     }
 73  258
     return errorCode.getErrorMessage();
 74  
   }
 75  121
 
 76  
   /**
 77  
    * Gets the exceptions' {@link nl.toolforge.karma.core.ErrorCode}.
 78  
    * @return
 79  
    */
 80  
   public final ErrorCode getErrorCode() {
 81  96
     return errorCode;
 82  
   }
 83  110
 
 84  
   public final Object[] getMessageArguments() {
 85  96
     return messageArguments;
 86  
   }
 87  110
 
 88  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.