net.scheinerman.phoenix.interpreter.exceptions
Class PhoenixRuntimeException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.lang.RuntimeException
              extended by net.scheinerman.phoenix.interpreter.exceptions.PhoenixRuntimeException
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
IOException, SyntaxException, UnsupportedOperatorException

public class PhoenixRuntimeException
extends java.lang.RuntimeException

This is the root of all exceptions that can be thrown during Phoenix program execution. Due to the fact that JBasic is not compiled, all exceptions that are thrown are RuntimeExceptions. This class provides the basic outline for Phoenix error output. All subclassed exceptions are expected to override the getErrorType() and getBriefMessage() methods to provide their own functionality. All exceptions are then to be caught and the printErrorMessage(String, String, int) is to be called, followed by a call to System.exit(int). The printErrorMessage(String, String, int) makes use of the two aforementioned methods in the print out in the following way:

**************************************************
getErrorType() found in file [file], line [lineN]:
Line: [line]
Error: getErrorMessage()
**************************************************


So for example the result of a call of printErrorMessage("fileName","nuf a = 24df", 2) on a JBasicRuntimeException object would provide the message:

**************************************************
Syntax error found in file test.phx, line 2:
Line: nuf a = 24df
Error: Generic syntax error
**************************************************

Since:
1.5
Version:
1.0
Author:
Jonah Scheinerman
See Also:
Serialized Form

Field Summary
private  java.lang.String briefMessage
          The slightly more descriptive phrase explaining the error.
private  java.lang.String errorType
          The basic error type of the exception, in this case it is, "Error".
private  int lastLine
           
private  boolean lastLineSet
           
private static long serialVersionUID
           
 
Constructor Summary
PhoenixRuntimeException()
          Default constructor, does nothing.
PhoenixRuntimeException(PhoenixRuntimeException e)
          Creates a new PhoenixRuntimException as a copy of another.
PhoenixRuntimeException(java.lang.String errorType, java.lang.String briefMessage)
           
 
Method Summary
 java.lang.String getBriefMessage()
          This returns a brief (one line) description of the error that occurred.
 java.lang.String getErrorType()
          This method returns the type of error for this particular exception.
 int getLastLine()
           
 boolean isLastLineSet()
           
 void printErrorMessage()
          This prints a standardized error message for this exception based on the results of the getErrorType() and getBriefMessage() methods.
 void setLastLine(int lastLine)
           
 void setLastLineSet(boolean lastLineSet)
           
 
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

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

errorType

private java.lang.String errorType
The basic error type of the exception, in this case it is, "Error".


briefMessage

private java.lang.String briefMessage
The slightly more descriptive phrase explaining the error. In this case it is "Generic error".


lastLine

private int lastLine

lastLineSet

private boolean lastLineSet
Constructor Detail

PhoenixRuntimeException

public PhoenixRuntimeException(PhoenixRuntimeException e)
Creates a new PhoenixRuntimException as a copy of another.

Parameters:
e - - The exception to be copied.

PhoenixRuntimeException

public PhoenixRuntimeException(java.lang.String errorType,
                               java.lang.String briefMessage)

PhoenixRuntimeException

public PhoenixRuntimeException()
Default constructor, does nothing.

Method Detail

getErrorType

public java.lang.String getErrorType()
This method returns the type of error for this particular exception. In this case the method returns the string literal "Syntax error".
Note: When subclassing this class, this method should be overridden to provide appropriate functionality.

Returns:
"Syntax Error"

getBriefMessage

public java.lang.String getBriefMessage()
This returns a brief (one line) description of the error that occurred. In this case the method returns the string literal "Generic error".
Note: When subclassing this class, this method should be overridden to provide appropriate functionality.

Returns:
"Generic error"

setLastLine

public void setLastLine(int lastLine)

getLastLine

public int getLastLine()

setLastLineSet

public void setLastLineSet(boolean lastLineSet)

isLastLineSet

public boolean isLastLineSet()

printErrorMessage

public final void printErrorMessage()
This prints a standardized error message for this exception based on the results of the getErrorType() and getBriefMessage() methods. This output is thoroughly described in the class description. The invocation of this method should be followed by a call to System.exit(int).

Parameters:
file - - the file that this error occurred in
line - - the line that this error occured on
lineN - - the number of the line that this error occured on