com.blackperl.Perl
Class TrException

java.lang.Object
  |
  +--java.lang.Throwable
        |
        +--java.lang.Exception
              |
              +--java.lang.RuntimeException
                    |
                    +--com.blackperl.Perl.TrException
All Implemented Interfaces:
java.io.Serializable

public final class TrException
extends java.lang.RuntimeException

A class for exceptions thrown by the Tr class. In some cases, exceptions from within the tr method may want to attach the pattern that was being analyzed when the exception occurred. For these cases, this class defines additional constructors (besides the ones inherited from java.lang.RuntimeException) that allow specifying the offending pattern. Receivers of exceptions constructed from this class may then use the getBadPattern method to later retrieve the pattern.

Using this approach, the message of the exception object can still be used to describe the exact nature of the error, and receivers do not have to resort to string-parsing or other manipulations to pull the pattern out of the message.

The one limitation here is that it is not possibly to create an exception object of this class with just the bad pattern. Because this signature conflicts with an existing constructor signature from the parent class, any attempt to set the pattern during initialization must use the forms documented here, in which at least one other parameter is also provided.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.lang.RuntimeException
 
Constructor Summary
TrException(java.lang.String message, java.lang.String pattern)
          Create an exception with the specified error message and offending tr pattern.
TrException(java.lang.String message, java.lang.Throwable cause, java.lang.String pattern)
          Create an exception with the specified error message, using the given Throwable instance as the cause, and the given tr pattern.
TrException(java.lang.Throwable cause, java.lang.String pattern)
          Create an exception using the given Throwable instance as the cause, and the given tr pattern.
 
Method Summary
 java.lang.String getBadPattern()
          Retrieve the offending pattern for this instance.
 
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
 

Constructor Detail

TrException

public TrException(java.lang.String message,
                   java.lang.String pattern)
Create an exception with the specified error message and offending tr pattern.

Parameters:
message - The message of the exception
pattern - The offending pattern string

TrException

public TrException(java.lang.String message,
                   java.lang.Throwable cause,
                   java.lang.String pattern)
Create an exception with the specified error message, using the given Throwable instance as the cause, and the given tr pattern.

Parameters:
message - The message of the exception
cause - The lower-level exception that led to this
pattern - The offending pattern string

TrException

public TrException(java.lang.Throwable cause,
                   java.lang.String pattern)
Create an exception using the given Throwable instance as the cause, and the given tr pattern.

Parameters:
cause - The lower-level exception that led to this
pattern - The offending pattern string
Method Detail

getBadPattern

public java.lang.String getBadPattern()
Retrieve the offending pattern for this instance. Note that once set, the pattern for an exception of this class becomes static and may not be modified.

Returns:
Returns the badPattern.