org.apache.cocoon.util.location
Class LocatedRuntimeException

java.lang.Object
  extended byjava.lang.Throwable
      extended byjava.lang.Exception
          extended byjava.lang.RuntimeException
              extended byorg.apache.commons.lang.exception.NestableRuntimeException
                  extended byorg.apache.cocoon.util.location.LocatedRuntimeException
All Implemented Interfaces:
Locatable, LocatableException, MultiLocatable, org.apache.commons.lang.exception.Nestable, Serializable

public class LocatedRuntimeException
extends org.apache.commons.lang.exception.NestableRuntimeException
implements LocatableException, MultiLocatable

A cascading and located RuntimeException. It is also MultiLocatable to easily build location stack traces.

If a LocatedRuntimeException is built with a location and a cause which is also a LocatedRuntimeException, then the default behavior is to add the location to the cause exception and immediately rethrow the cause. This avoids exception nesting and builds a location stack.

Since:
2.1.8
Version:
$Id: LocatedRuntimeException.html 1304280 2012-03-23 11:18:01Z ilgrosso $
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.apache.commons.lang.exception.NestableRuntimeException
delegate
 
Constructor Summary
LocatedRuntimeException(String message)
           
LocatedRuntimeException(String message, Location location)
           
LocatedRuntimeException(String message, Throwable cause)
           
LocatedRuntimeException(String message, Throwable cause, Location location)
           
LocatedRuntimeException(String message, Throwable cause, Location location, boolean rethrowLocated)
           
 
Method Summary
 void addLocation(Location loc)
          Add a location to the current list of locations.
 Location getLocation()
          Get the location of this object
 List getLocations()
          Return the list of locations.
 String getMessage()
           
 String getRawMessage()
          Get the raw message of the exception (the one used in the constructor)
 
Methods inherited from class org.apache.commons.lang.exception.NestableRuntimeException
getCause, getMessage, getMessages, getThrowable, getThrowableCount, getThrowables, indexOfThrowable, indexOfThrowable, printPartialStackTrace, printStackTrace, printStackTrace, printStackTrace
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getLocalizedMessage, getStackTrace, initCause, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LocatedRuntimeException

public LocatedRuntimeException(String message)

LocatedRuntimeException

public LocatedRuntimeException(String message,
                               Throwable cause)
                        throws LocatedRuntimeException

LocatedRuntimeException

public LocatedRuntimeException(String message,
                               Location location)

LocatedRuntimeException

public LocatedRuntimeException(String message,
                               Throwable cause,
                               Location location)
                        throws LocatedRuntimeException

LocatedRuntimeException

public LocatedRuntimeException(String message,
                               Throwable cause,
                               Location location,
                               boolean rethrowLocated)
                        throws LocatedRuntimeException
Method Detail

getLocation

public Location getLocation()
Description copied from interface: Locatable
Get the location of this object

Specified by:
getLocation in interface Locatable
Returns:
the location

getLocations

public List getLocations()
Description copied from interface: MultiLocatable
Return the list of locations.

Specified by:
getLocations in interface MultiLocatable
Returns:
a list of locations, possibly empty but never null.

getRawMessage

public String getRawMessage()
Description copied from interface: LocatableException
Get the raw message of the exception (the one used in the constructor)

Specified by:
getRawMessage in interface LocatableException
Returns:
the raw message

getMessage

public String getMessage()
Specified by:
getMessage in interface org.apache.commons.lang.exception.Nestable

addLocation

public void addLocation(Location loc)
Description copied from interface: MultiLocatable
Add a location to the current list of locations.

Implementations are free to filter locations that can be added (e.g. Location.UNKNOWN), and there is therefore no guarantee that the given location will actually be added to the list. Filtered locations are silently ignored.

Specified by:
addLocation in interface MultiLocatable
Parameters:
loc - the location to be added.


Copyright 1999-2008 The Apache Software Foundation. All Rights Reserved.