Hyperic HQ Plugin API v. 4.4.0.2

org.hyperic.util
Class NestedException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by org.hyperic.util.NestedException
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
AccountDisabledException, ActionCreateException, AgentCallbackClientException, ApplicationException, AutoinventoryException, CertificateCreateException, EncodingException, InvalidTriggerDataException, LiveDataException, LiveMeasurementException, MatcherException, MeasurementConfigException, MonitorAgentException, PageFetchException, ParseException, PasswordIsNullException, PluginException, PrivilegeCheckException, PropertyNotFoundException, ScheduleException, ScheduleParseException, ServerStillStartingException, ShellCommandExecException, ShellCommandInitException, ShellCommandUsageException, SNMPException, SSHExecException, SSHRemoteException, UnscheduleException

public abstract class NestedException
extends java.lang.Exception

A simple class that provides for nested exceptions.

See Also:
Serialized Form

Field Summary
protected  java.util.Vector _exception
           
 
Constructor Summary
NestedException()
          Empty constructor, not very useful
NestedException(java.lang.String s)
          String constructor, a little more useful
NestedException(java.lang.String s, java.lang.Throwable t)
          Useful for revealing the original error with a bonus message.
NestedException(java.lang.String s, java.util.Vector excV)
          Useful for revealing the original error when there may be a stack of them, plus you get an extra special bonus message! Constructor takes a string and a Vector of Throwables.
NestedException(java.lang.Throwable t)
          Useful for revealing the original error.
 
Method Summary
 void addException(java.lang.Throwable t)
           
 java.lang.Throwable getExceptionOfType(java.lang.Class exceptionType)
          Checks to see if this NestedException contains any exception of the given type.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_exception

protected java.util.Vector _exception
Constructor Detail

NestedException

public NestedException()
Empty constructor, not very useful


NestedException

public NestedException(java.lang.String s)
String constructor, a little more useful


NestedException

public NestedException(java.lang.Throwable t)
Useful for revealing the original error. Constructor takes something throwable and adds it to a collection that can later be dumped out by toString() and/or printStackTrace()


NestedException

public NestedException(java.lang.String s,
                       java.lang.Throwable t)
Useful for revealing the original error with a bonus message. Constructor takes a string and something throwable. Adds the throwable item to a collection that can later be dumped out by toString() and/or printStackTrace()


NestedException

public NestedException(java.lang.String s,
                       java.util.Vector excV)
Useful for revealing the original error when there may be a stack of them, plus you get an extra special bonus message! Constructor takes a string and a Vector of Throwables. Adds the throwable items to a collection that can later be dumped out by toString() and/or printStackTrace() Use this when nesting try/catch blocks The advantage of this one is that you don't need to construct your exception in advance, just create the Vector and add() them as you go. In the end, throw with this constructor if the Vector's size() != 0

Method Detail

addException

public void addException(java.lang.Throwable t)

getExceptionOfType

public java.lang.Throwable getExceptionOfType(java.lang.Class exceptionType)
Checks to see if this NestedException contains any exception of the given type. If it does, this method returns the first such instance found. This DOES descend into exceptions contained within this exception, so for example if you were looking for an exception of type T1, and this NestedException was of type T2 and contained another NestedException of T3, which in turn contained an exception of type T1, this method won't return null, because the exception is nested by this object.

Thorougly confused? Ask Jonathan - he's the bastard writing this kludgy workaround because jbrewer changed this class during the time that Jonathan's SNMPmgr code was out of the build cycle. Jonathan's code depended on a "getBaseException" method in this class, which is now meaningless because there can be multiple (in a Vector) base exceptions. Grrr....

Parameters:
exceptionType - The exception type to look for.
Returns:
The first instance of the exception type found, or null if not found.

Hyperic HQ Plugin API v. 4.4.0.2

Copyright © 2004-2006 Hyperic, Inc. support@hyperic.net, All Rights Reserved.