Error reporting

This chapter contains information about error reporting during execution and compilation.

Environment errors

Environment errors are errors that occur during script execution or using API functions. When such an error occur there is called a callback function that can be passed by user. All functions or macros return NULL or 0 in case of some error. To get the reason of the error you must set the callback at initialization time.


   void EnvErrorCallback(SCENVERROR err, PCStr desc, void *userData);
   ...
   ISCEnvDesc envDesc;
   envDesc.envErrorCallback = EnvErrorCallback; //pointer to your EnvErrorCallback function
   envDesc.envErrorCallbackUserData = EnvErrorCallbackData; //some data pointer if necessary   

The first parameter of the above callback is an error code (see reference), desc is an optional description, userData is ISCEnvDesc::envErrorCallbackUserData field specified by the user.

Compilation errors

When compiling a script you can get information about errors that are in the code.

   void CompileErrorCallback(const SCCompileError *err, void *userData);
   ...
   ISCEnvDesc envDesc;
   envDesc.compileErrorCallback = CompileErrorCallback;
   envDesc.compileErrorCallbackUserData = CompileErrorCallbackData;   

The first parameter is a pointer to the error description structure:

   

typedef struct SCCompileError
{
	SCCOMPERROR code;         //code 
	PCStr       path;         //script path
	PCStr       tokenName;    //name of token that error occured at
	Int         row;          //y character position (from 1)
	Int         col;          //x character position (from 1)
	PCStr       msg;          //additional information (optional)
  ...
}SCCompileError;

You can use it to compose your own error information.