Falcon::Error Class Reference

The Error class. More...

#include <error.h>

Inheritance diagram for Falcon::Error:

Inheritance graph

List of all members.

Public Member Functions

void addTrace (const String &module, const String &symbol, uint32 line, uint32 pc)
void appendSubError (Error *sub)
bool catchable () const
void catchable (bool c)
uint32 character () const
void character (uint32 chr)
const StringclassName () const
virtual Errorclone () const
void decref ()
 Error (const ErrorParam &params)
 Error ()
int errorCode () const
void errorCode (int ecode)
const StringerrorDescription () const
void errorDescription (const String &errorDesc)
const StringextraDescription () const
void extraDescription (const String &extra)
bool hasTraceback () const
virtual Stringheading (String &target) const
 Writes only the heading of the error to the target string.
void incref ()
uint32 line () const
void line (uint32 line)
const Stringmodule () const
void module (const String &moduleName)
bool nextStep (String &module, String &symbol, uint32 &line, uint32 &pc)
t_origin origin () const
void origin (t_origin o)
uint32 pcounter () const
void pcounter (uint32 pc)
const Itemraised () const
void raised (const Item &itm)
void rewindStep ()
virtual CoreObjectscriptize (VMachine *vm)
 Returns an object that can be set in a Falcon item and handled by a script.
ErrorsubError () const
const Stringsymbol () const
void symbol (const String &symbolName)
uint32 systemError () const
void systemError (uint32 ecode)
virtual StringtoString (String &target) const
String toString () const

Protected Member Functions

 Error (const String &className, const ErrorParam &params)
 Minimal constructor.
 Error (const Error &e)
 Copy constructor.
 Error (const String &className)
 Empty constructor.
virtual ~Error ()
 Private destructor.

Protected Attributes

bool m_catchable
uint32 m_character
String m_className
String m_description
int m_errorCode
String m_extra
uint32 m_line
String m_module
t_origin m_origin
uint32 m_pc
Item m_raised
int32 m_refCount
List m_steps
String m_symbol
uint32 m_sysError

Detailed Description

The Error class.

This class implements an error instance. Errors represent problems occoured both during falcon engine operations (i.e. compilation syntax errors, link errors, file I/O errors, dynamic library load errors ands o on) AND during runtime (i.e. VM opcode processing errors, falcon program exceptions, module function errors).

When an error is raised by an engine element whith this capability (i.e. the compiler, the assembler, the runtime etc.), it is directly passed to the error handler, which has the duty to do something with it and eventually destroy it.

When an error is raised by a module function with the VMachine::raiseError() method, the error is stored in the VM; if the error is "catchable" AND it occours inside a try/catch statement, it is turned into a Falcon Error object and passed to the script.

When a script raises an error both explicitly via the "raise" function or by performing a programming error (i.e. array out of bounds), if there is a try/catch block at work the error is turned into a Falcon error and passed to the script.

If there isn't a try/catch block or if the error is raised again by the script, the error instance is passed to the VM error handler.

Scripts may raise any item, which may not necessary be Error instances. The item is then copied in the m_item member and passed to the error handler.

Constructor & Destructor Documentation

Falcon::Error::Error ( const String className  )  [inline, protected]

Empty constructor.

The error must be filled with proper values.

Falcon::Error::Error ( const Error e  )  [protected]

Copy constructor.

Falcon::Error::Error ( const String className,
const ErrorParam params 
) [inline, protected]

Minimal constructor.

If the description is not filled, the toString() method will use the default description for the given error code.

virtual Falcon::Error::~Error (  )  [protected, virtual]

Private destructor.

Can be destroyed only via decref.

Falcon::Error::Error (  )  [inline]

Falcon::Error::Error ( const ErrorParam params  )  [inline]

Member Function Documentation

void Falcon::Error::addTrace ( const String module,
const String symbol,
uint32  line,
uint32  pc 

void Falcon::Error::appendSubError ( Error sub  ) 

bool Falcon::Error::catchable (  )  const [inline]

void Falcon::Error::catchable ( bool  c  )  [inline]

uint32 Falcon::Error::character (  )  const [inline]

void Falcon::Error::character ( uint32  chr  )  [inline]

const String& Falcon::Error::className (  )  const [inline]

virtual Error* Falcon::Error::clone (  )  const [virtual]

void Falcon::Error::decref (  ) 

int Falcon::Error::errorCode (  )  const [inline]

void Falcon::Error::errorCode ( int  ecode  )  [inline]

const String& Falcon::Error::errorDescription (  )  const [inline]

void Falcon::Error::errorDescription ( const String errorDesc  )  [inline]

const String& Falcon::Error::extraDescription (  )  const [inline]

void Falcon::Error::extraDescription ( const String extra  )  [inline]

bool Falcon::Error::hasTraceback (  )  const [inline]

virtual String& Falcon::Error::heading ( String target  )  const [virtual]

Writes only the heading of the error to the target string.

The error heading is everything of the error without the traceback. This method never recurse on error lists; only the first heading is returned.

the input target string is not cleared; error contents are added at at the end.

The returned string doesn't terminate with a "\n".

void Falcon::Error::incref (  ) 

uint32 Falcon::Error::line (  )  const [inline]

void Falcon::Error::line ( uint32  line  )  [inline]

const String& Falcon::Error::module (  )  const [inline]

void Falcon::Error::module ( const String moduleName  )  [inline]

bool Falcon::Error::nextStep ( String module,
String symbol,
uint32 line,
uint32 pc 

t_origin Falcon::Error::origin (  )  const [inline]

void Falcon::Error::origin ( t_origin  o  )  [inline]

uint32 Falcon::Error::pcounter (  )  const [inline]

void Falcon::Error::pcounter ( uint32  pc  )  [inline]

const Item& Falcon::Error::raised (  )  const [inline]

void Falcon::Error::raised ( const Item itm  )  [inline]

void Falcon::Error::rewindStep (  ) 

virtual CoreObject* Falcon::Error::scriptize ( VMachine vm  )  [virtual]

Returns an object that can be set in a Falcon item and handled by a script.

This method converts the error object in a Falcon Object, derived from the proper class.

The method must be fed with a virtual machine. The target virtual machine should have linked a module providing a "specular class". This method will search the given VM for a class having the same name as the one that is returned by the className() method (set in the constructor by the subclasses of Error), and it will create an instance of that class. The method will then fill the resulting object with the needed values, and finally it will set itself as the User Data of the given object.

The target class Falcon should be a class derived from the Core class "Error", so that the inherited methods as "toString" and "traceback" are inherited too, and so that a check on "Error" inheritance will be positive.

Error* Falcon::Error::subError (  )  const [inline]

const String& Falcon::Error::symbol (  )  const [inline]

void Falcon::Error::symbol ( const String symbolName  )  [inline]

uint32 Falcon::Error::systemError (  )  const [inline]

void Falcon::Error::systemError ( uint32  ecode  )  [inline]

virtual String& Falcon::Error::toString ( String target  )  const [virtual]

String Falcon::Error::toString (  )  const [inline]

References toString().

Referenced by toString().

Member Data Documentation

bool Falcon::Error::m_catchable [protected]

int Falcon::Error::m_errorCode [protected]

The documentation for this class was generated from the following file:

Generated on Mon Oct 19 10:11:34 2009 for Falcon_Core by  doxygen 1.5.8