org.apache.cocoon.util.location
Class LocatedException

java.lang.Object
  extended byjava.lang.Throwable
      extended byjava.lang.Exception
          extended byorg.apache.cocoon.util.location.LocatedException
All Implemented Interfaces:
Locatable, LocatableException, MultiLocatable, Serializable
Direct Known Subclasses:
ProcessingException

public class LocatedException
extends Exception
implements LocatableException, MultiLocatable

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

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

Constructor Summary
LocatedException(String message)
           
LocatedException(String message, Location location)
           
LocatedException(String message, Throwable cause)
           
LocatedException(String message, Throwable cause, Location location)
           
 
Method Summary
static void addCauseLocations(MultiLocatable self, Throwable cause)
          Add to the location stack all locations of an exception chain.
 void addLocation(Location loc)
          Add a location to the current list of locations.
static void ensureCauseChainIsSet(Throwable thr)
          Crawl the cause chain and ensure causes are properly set using Throwable.initCause(java.lang.Throwable).
 Location getLocation()
          Get the location of this object
 List getLocations()
          Return the list of locations.
 String getMessage()
           
static String getMessage(String message, List locations)
          Standard way of building the message of a LocatableException, as a Java-like stack trace of locations.
 String getRawMessage()
          Get the raw message of the exception (the one used in the constructor)
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LocatedException

public LocatedException(String message)

LocatedException

public LocatedException(String message,
                        Throwable cause)

LocatedException

public LocatedException(String message,
                        Location location)

LocatedException

public LocatedException(String message,
                        Throwable cause,
                        Location location)
Method Detail

ensureCauseChainIsSet

public static void ensureCauseChainIsSet(Throwable thr)
Crawl the cause chain and ensure causes are properly set using Throwable.initCause(java.lang.Throwable). This is needed because some exceptions (e.g. SAXException) don't have a Throwable.getCause() that is used to print stacktraces.


addCauseLocations

public static void addCauseLocations(MultiLocatable self,
                                     Throwable cause)
Add to the location stack all locations of an exception chain. This allows to have all possible location information in the stacktrace, as some exceptions like SAXParseException don't output their location in printStackTrace().

Traversal of the call chain stops at the first Locatable exception which is supposed to handle the loction of its causes by itself.

This method is static as a convenience for other implementations of locatable exceptions.

Parameters:
self - the current locatable exception
cause - a cause of self

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 static String getMessage(String message,
                                List locations)
Standard way of building the message of a LocatableException, as a Java-like stack trace of locations.

Parameters:
message - the exception's message, given by super.getMessage() (can be null)
locations - the location list (can be null)
Returns:
the message, or null no message and locations were given.

getMessage

public String getMessage()

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.