setErrorUserData()
Sets any variable as userData in the errClass object.
Synopsis
int setErrorUserData(errClass &err, mixed userData);
Parameters
| Parameter | Description |
|---|---|
| err | The errClass object in which the userData is set. |
| userData | The userData that is set. |
Return value
Returns -1 on error and returns 0 on success.
Description
Sets any variable as userData in the errClass object. If the errClass already has userData, this is overwritten.
The userData of the errClass can be accessed with the function getErrorUserData(...).
Example
float main()
{
try
{
int dividend = 10;
int divisor = 0;
if (divisor == 0) //division by 0 error
{
errClass err = makeError("", PRIO_FATAL, ERR_CONTROL, 0, "Division by zero error");
setErrorUserData(err, makeDynInt(dividend, divisor));
throw(err);
}
return dividend / divisor;
}
catch
{
dyn_errClass exceptions = getLastException();
dyn_int operationValues;
getErrorUserData(exceptions, operationValues);
DebugN(getErrorText(exceptions), "Dividend = " + operationValues[1], "Divisor = " + operationValues[2]);
return maxFLOAT();
}
}
