2009/04/15 - Apache HiveMind has been retired.

For more information, please explore the Attic.

Clover coverage report - Code Coverage for hivemind release 1.2.1
Coverage timestamp: Fri Feb 10 2006 16:33:43 PST
file stats: LOC: 112   Methods: 10
NCLOC: 58   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ApplicationRuntimeException.java 100% 100% 100% 100%
coverage
 1    // Copyright 2004, 2005 The Apache Software Foundation
 2    //
 3    // Licensed under the Apache License, Version 2.0 (the "License");
 4    // you may not use this file except in compliance with the License.
 5    // You may obtain a copy of the License at
 6    //
 7    // http://www.apache.org/licenses/LICENSE-2.0
 8    //
 9    // Unless required by applicable law or agreed to in writing, software
 10    // distributed under the License is distributed on an "AS IS" BASIS,
 11    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12    // See the License for the specific language governing permissions and
 13    // limitations under the License.
 14   
 15    package org.apache.hivemind;
 16   
 17    /**
 18    * General wrapper for any exception (normal or runtime) that may occur during runtime processing
 19    * for the application. This is exception is used when the intent is to communicate a low-level
 20    * failure to the user or developer; it is not expected to be caught. The
 21    * {@link #getRootCause() rootCause} property is a <em>nested</em> exception.
 22    *
 23    * @author Howard Lewis Ship
 24    */
 25   
 26    public class ApplicationRuntimeException extends RuntimeException implements Locatable
 27    {
 28    private static final long serialVersionUID = 1L;
 29   
 30    private Throwable _rootCause;
 31   
 32    private transient Location _location;
 33   
 34    private transient Object _component;
 35   
 36  2 public ApplicationRuntimeException(Throwable rootCause)
 37    {
 38  2 this(rootCause.getMessage(), rootCause);
 39    }
 40   
 41  57 public ApplicationRuntimeException(String message)
 42    {
 43  57 this(message, null, null, null);
 44    }
 45   
 46  23 public ApplicationRuntimeException(String message, Throwable rootCause)
 47    {
 48  23 this(message, null, null, rootCause);
 49    }
 50   
 51  124 public ApplicationRuntimeException(String message, Object component, Location location,
 52    Throwable rootCause)
 53    {
 54  124 super(message);
 55   
 56  124 _rootCause = rootCause;
 57  124 _component = component;
 58   
 59  124 _location = HiveMind.findLocation(new Object[]
 60    { location, rootCause, component });
 61    }
 62   
 63  33 public ApplicationRuntimeException(String message, Location location, Throwable rootCause)
 64    {
 65  33 this(message, null, location, rootCause);
 66    }
 67   
 68  7 public Throwable getRootCause()
 69    {
 70  7 return _rootCause;
 71    }
 72   
 73  17 public Location getLocation()
 74    {
 75  17 return _location;
 76    }
 77   
 78  7 public Object getComponent()
 79    {
 80  7 return _component;
 81    }
 82   
 83    /**
 84    * This method is for compatibility with JDK 1.4. Under 1.4, this will look like an override,
 85    * allowing <code>printStackTrace()</code> to descending into the root cause exception and
 86    * print its stack trace too.
 87    */
 88  2 public Throwable getCause()
 89    {
 90  2 return _rootCause;
 91    }
 92   
 93    /**
 94    * Overrides the default implementation of <code>toString</code>, suffixing the normal result
 95    * with the {@link #getLocation() location} of the exception (if non null). Example:
 96    * <code>org.apache.hivemind.ApplicationRuntimeException: Exception Message [file:foo/bar/baz, line 13]</code>.
 97    *
 98    * @since 1.1
 99    */
 100  5 public String toString()
 101    {
 102  5 if (_location == null)
 103  4 return super.toString();
 104   
 105  1 StringBuffer buffer = new StringBuffer(super.toString());
 106  1 buffer.append(" [");
 107  1 buffer.append(_location);
 108  1 buffer.append("]");
 109   
 110  1 return buffer.toString();
 111    }
 112    }