sqrat  0.9
sqrat
 All Classes Functions Variables Enumerations Enumerator Pages
Public Member Functions | Static Public Member Functions | List of all members
Sqrat::Error Class Reference

#include <sqratUtil.h>

Public Member Functions

void Clear (HSQUIRRELVM vm)
 
string Message (HSQUIRRELVM vm)
 
bool Occurred (HSQUIRRELVM vm)
 
void Throw (HSQUIRRELVM vm, const string &err)
 

Static Public Member Functions

static ErrorInstance ()
 
static string FormatTypeError (HSQUIRRELVM vm, SQInteger idx, const string &expectedType)
 

Detailed Description

The class that must be used to deal with errors that Sqrat has

Remarks
When documentation in Sqrat says, "This function MUST have its error handled if it occurred," that means that after the function has been run, you must call Error::Occurred to see if the function ran successfully. If the function did not run successfully, then you must either call Error::Clear or Error::Message to clear the error buffer so new ones may occur and Sqrat does not get confused.
Any error thrown inside of a bound C++ function will be also thrown in the given Squirrel VM.
If compiling with SCRAT_NO_ERROR_CHECKING defined, Sqrat will run significantly faster, but it will no longer check for errors and the Error class itself will not be defined. In this mode, a Squirrel script may crash the C++ application if errors occur in it.

Member Function Documentation

void Sqrat::Error::Clear ( HSQUIRRELVM  vm)
inline

Clears the error associated with a given VM

Parameters
vmTarget VM
static string Sqrat::Error::FormatTypeError ( HSQUIRRELVM  vm,
SQInteger  idx,
const string &  expectedType 
)
inlinestatic

Returns a string that has been formatted to give a nice type error message (for usage with Class::SquirrelFunc)

Parameters
vmVM the error occurred with
idxIndex on the stack of the argument that had a type error
expectedTypeThe name of the type that the argument should have been
Returns
String containing a nice type error message
static Error& Sqrat::Error::Instance ( )
inlinestatic

Gets the Error instance (this class uses a singleton pattern)

Returns
Error instance
string Sqrat::Error::Message ( HSQUIRRELVM  vm)
inline

Clears the error associated with a given VM and returns the associated error message

Parameters
vmTarget VM
Returns
String containing a nice error message
bool Sqrat::Error::Occurred ( HSQUIRRELVM  vm)
inline

Returns whether a Sqrat error has occurred with a given VM

Parameters
vmTarget VM
Returns
True if an error has occurred, otherwise false
void Sqrat::Error::Throw ( HSQUIRRELVM  vm,
const string &  err 
)
inline

Raises an error in a given VM with a given error message

Parameters
vmTarget VM
errA nice error message

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