org.hecl
Class HeclException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by org.hecl.HeclException
All Implemented Interfaces:
java.io.Serializable

public class HeclException
extends java.lang.Exception

The HeclException class implements exceptions for Hecl.

Version:
1.0
Author:
David N. Welton
See Also:
Serialized Form

Field Summary
 java.lang.String code
           
 
Constructor Summary
HeclException(java.lang.String s)
          Creates a new HeclException instance.
HeclException(java.lang.String s, int lineno)
           
HeclException(java.lang.String s, java.lang.String exception_code)
          Creates a new HeclException instance.
 
Method Summary
static java.lang.StringBuffer argvToString(Thing[] argv)
          The argvToString method turns an argv array into a string, suitable for printing in error messages.
static java.lang.StringBuffer argvToString(Thing[] argv, int count)
          The argvToString method turns an argv array into a string, suitable for printing in error messages.
static HeclException createInvalidParameter(Thing param, java.lang.String type, java.lang.String options)
           
static HeclException createWrongNumArgsException(Thing[] argv, int count, java.lang.String message)
          The createWrongNumArgsException method creates a HeclException for a command that has received the wrong number of arguments.
 Thing getStack()
          The getStack method returns the exception as a Thing.
 void setLine(int lineno)
          The setLine method sets the line number of an error.
 java.lang.String toString()
          The toString method turns the exception stack into a string.
 void where(java.lang.String cmd, int lineno)
          The where method tells the exception what command it occurred in.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

code

public java.lang.String code
Constructor Detail

HeclException

public HeclException(java.lang.String s)
Creates a new HeclException instance.

Parameters:
s - a String value

HeclException

public HeclException(java.lang.String s,
                     int lineno)

HeclException

public HeclException(java.lang.String s,
                     java.lang.String exception_code)
Creates a new HeclException instance.

Parameters:
s - a String value describing the error.
exception_code - an int value
Method Detail

where

public void where(java.lang.String cmd,
                  int lineno)
The where method tells the exception what command it occurred in.

Parameters:
cmd - a String containing the command name.

toString

public java.lang.String toString()
The toString method turns the exception stack into a string.

Overrides:
toString in class java.lang.Throwable
Returns:
a String value

getStack

public Thing getStack()
The getStack method returns the exception as a Thing.

Returns:
a Thing value

argvToString

public static java.lang.StringBuffer argvToString(Thing[] argv)
The argvToString method turns an argv array into a string, suitable for printing in error messages.

Parameters:
argv - a Thing value
Returns:
a StringBuffer value

argvToString

public static java.lang.StringBuffer argvToString(Thing[] argv,
                                                  int count)
The argvToString method turns an argv array into a string, suitable for printing in error messages.

Parameters:
argv - a Thing value
count - a Thing value
Returns:
a StringBuffer value

createWrongNumArgsException

public static HeclException createWrongNumArgsException(Thing[] argv,
                                                        int count,
                                                        java.lang.String message)
                                                 throws HeclException
The createWrongNumArgsException method creates a HeclException for a command that has received the wrong number of arguments.

Parameters:
argv - a Thing value
count - an int value
message - a String value
Returns:
a HeclException value
Throws:
HeclException - if an error occurs

createInvalidParameter

public static HeclException createInvalidParameter(Thing param,
                                                   java.lang.String type,
                                                   java.lang.String options)
                                            throws HeclException
Parameters:
param - Thing specifying the actual parameter.
type - String saying the type - ie option , command .
options - A comma-separated list of options that can be supplied.
Returns:
a new HeclException
Throws:
HeclException

setLine

public void setLine(int lineno)
             throws HeclException
The setLine method sets the line number of an error. FIXME - this could probably be done in a cleaner way...

Parameters:
lineno - an int value
Throws:
HeclException - if an error occurs