Phantom Documentation

[Help Home] [Phantom Home]
Logging Errors

Phantom allows for user-defined errors and warnings. As such, it provides the exception data type. An exception can be created with an error message, a warning message, or a user defined message type. The exception can then be 'thrown' using the exception's throw member function. When the exception is thrown, it is as though an error or warning occurred, and it is processed like any other Phantom error or warning. Exceptions thrown from an exception data type will be caught by try-catch statements, and will also increment any error and warning counters.

Example Code

# Declare the exceptions
exception e;
exception w;

# Set error and warning exceptions
e.SetError("Sample Error");
w.SetWarning("Sample Warning");

# Throw the warning
w.throw();

# Throw and catch the error
try{
  e.throw();
}catch(exception ex){
  disp("Exception Caught: " + ex.GetMessage());
}

# Throw the error without catching it
e.throw();



The output from the above sample code is

Output
** WARNING: (1) from 'Sample.psc' on line 10 - Sample Warning
Exception Caught: Sample Error
** ERROR: (1) from 'Sample.psc' on line 20 - Sample Error


See Also: exceptions

Deprecated (after Phantom v1.1):
Phantom allows the user to log errors manually.  This is done using the 'LogError' function.  This function writes error output to both the screen and the output file as though an error was produced by Phantom.

For more information, view the LogError definition.

See Also: LogError, Log, Output


Copyright 2000-2011 Phantom Automated Solutions