com.waveset.object
Class ResultError

java.lang.Object
  extended bycom.waveset.util.AbstractXmlObject
      extended bycom.waveset.object.ResultError
All Implemented Interfaces:
javax.naming.Referenceable, XmlObject

public class ResultError
extends AbstractXmlObject

A class used to represent information about an error that happened during some operation, which needs to be stored in a WavesetResult object.

These will be found in ResultItem objects whose type is "error". There are two basic ways to build one of these:

  1. By supplying one or more Message objects containing the error messages.
  2. By supplying a Throwable object in which case we'll capture information in the object.

  3. Field Summary
    static java.lang.String ATT_THROWABLE
               
    static java.lang.String code_id
               
    static java.lang.String EL_STACK
               
    static java.lang.String ELEMENT
              Our XML element name.
    static java.lang.String ITEM_TYPE
              The ResultItem type name for these.
     
    Fields inherited from class com.waveset.util.AbstractXmlObject
    _trace
     
    Constructor Summary
    ResultError()
              Build an empty error object, which can be populated manually.
    ResultError(org.w3c.dom.Element e)
              Build an error object by parsing its DOM representation.
    ResultError(Message msg)
              Build an error object that captures a single Message object.
    ResultError(java.lang.Throwable t)
              Build an error object that captures the state of a Throwable.
     
    Method Summary
     java.lang.String getElementName()
              Return the XML element name, required by AbstractXmlObject.
     java.lang.String getFirstStackTrace()
              Get the stack trace of the innermost nested error.
     java.lang.String getMessage()
              Render the message hierarchy as a string in the current locale.
     java.lang.String getMessage(java.util.Locale locale)
              Render the message hierarchy as a string.
     Message[] getMessages()
              Get the array of message objects.
     ResultError[] getNestedErrors()
              Get the nested error objects, if this error was constructed from a list of wrapped exceptions.
     java.lang.String getStackTrace()
              Get the stack trace found on the Throwable object from which this error object was built.
     java.lang.String getThrowableClass()
              Get the name of the Throwable class from which this error object was built.
     void setMessages(Message[] msgs)
              Set the array of message objects.
     void setNestedErrors(ResultError[] e)
              Set the nested error objects.
     void setStackTrace(java.lang.String s)
              Get the stack trace found on the Throwable object from which this error object was built.
     void setThrowableClass(java.lang.String name)
              Set the name of the Throwable class from which this error object was built.
     java.lang.String toString()
               
     void toXml(java.lang.StringBuffer b, int indent)
              Serialize into a buffer with optional indentation.
     
    Methods inherited from class com.waveset.util.AbstractXmlObject
    addXmlHeader, cloneObject, dump, dumpFile, getReference, println, setTrace, toIdentityString, toVerboseString, toVerboseString, toXml, toXml, toXml
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
     

    Field Detail

    code_id

    public static final java.lang.String code_id
    See Also:
    Constant Field Values

    ELEMENT

    public static final java.lang.String ELEMENT
    Our XML element name.

    See Also:
    Constant Field Values

    ITEM_TYPE

    public static final java.lang.String ITEM_TYPE
    The ResultItem type name for these. Should this go here or in ResultItem?

    See Also:
    Constant Field Values

    ATT_THROWABLE

    public static final java.lang.String ATT_THROWABLE
    See Also:
    Constant Field Values

    EL_STACK

    public static final java.lang.String EL_STACK
    See Also:
    Constant Field Values
    Constructor Detail

    ResultError

    public ResultError()
    Build an empty error object, which can be populated manually.


    ResultError

    public ResultError(Message msg)
    Build an error object that captures a single Message object. You might use this just to capture random error messages that don't originate through exceptions.


    ResultError

    public ResultError(java.lang.Throwable t)
    Build an error object that captures the state of a Throwable. Usually this is a WavesetException but it doesn't have to be.


    ResultError

    public ResultError(org.w3c.dom.Element e)
                throws WavesetException
    Build an error object by parsing its DOM representation.

    Method Detail

    getElementName

    public java.lang.String getElementName()
    Return the XML element name, required by AbstractXmlObject.

    Specified by:
    getElementName in interface XmlObject
    Specified by:
    getElementName in class AbstractXmlObject

    getMessages

    public Message[] getMessages()
    Get the array of message objects. This should normally be non-null, but there is no guarentee that it is.


    setMessages

    public void setMessages(Message[] msgs)
    Set the array of message objects. This should only be called when building ResultError objects manually, it is meaningless to modify message objects after construction.


    getNestedErrors

    public ResultError[] getNestedErrors()
    Get the nested error objects, if this error was constructed from a list of wrapped exceptions.


    setNestedErrors

    public void setNestedErrors(ResultError[] e)
    Set the nested error objects. This should only be called when building ResultError objects manually, it is meaningless to modify the nested error after construction.


    getThrowableClass

    public java.lang.String getThrowableClass()
    Get the name of the Throwable class from which this error object was built. This may be null if this object was just constructed to contain one or more Message objects.

    We return the name of the class rather than a Class object, since the code examining the ResultError is not necessarily in a context that is able to instantiate the throwable class.


    setThrowableClass

    public void setThrowableClass(java.lang.String name)
    Set the name of the Throwable class from which this error object was built. This should only be called when building ResultError objects manually, it is meaningless to modify the class name after construction.


    getStackTrace

    public java.lang.String getStackTrace()
    Get the stack trace found on the Throwable object from which this error object was built.


    setStackTrace

    public void setStackTrace(java.lang.String s)
    Get the stack trace found on the Throwable object from which this error object was built. This should only be called when building ResultError objects manually, it is meaningless to modify the stack after construction.


    getFirstStackTrace

    public java.lang.String getFirstStackTrace()
    Get the stack trace of the innermost nested error. This is the one that is usually the most interesting since it contains the stack of the original exception. The stacks of the wrapped exceptions usually do not contain the true cause of the error.

    If there is more than one wrapped exception, we follow the leftmost path.


    getMessage

    public java.lang.String getMessage(java.util.Locale locale)
    Render the message hierarchy as a string.


    getMessage

    public java.lang.String getMessage()
    Render the message hierarchy as a string in the current locale.


    toString

    public java.lang.String toString()

    toXml

    public void toXml(java.lang.StringBuffer b,
                      int indent)
    Description copied from class: AbstractXmlObject
    Serialize into a buffer with optional indentation. This must be implemented by the subclass.

    Specified by:
    toXml in interface XmlObject
    Specified by:
    toXml in class AbstractXmlObject