RSetLastErr()

Sets current error status.

Synopsis

void RSetLastErr( int err_code, string err_desc, int userData = 0);

Parameters

Parameter Description
err_code

Error code to be set.

Every function of the R control extension sets the error status to a value unequal to 0 if an error occurred.

If the error status is already unequal to 0 when an R control extension function is called, the function is not executed and the error status is not modified if the error lock mechanism is active. This enables the correct error handling when chaining R control extension functions.

err_desc Error description to be set
userData

Optional parameter. Context in which error occurred.You can call an R control extension function with the int parameter "userData". This value is stored in the error context structure regardless if an error occurred or not. By passing a unique userData, values are passed to chained R control extension functions and the function where an error occurred can be identified afterwards.

If -1 is passed, the last error context, which was set by a previous function where no error occurred, is not changed.

Return Value

The function returns the error status value (0 = no error)

Description

Sets current error status.

Example

Creates and returns an error.

#uses "CtrlR"
main()
{
  int userData = 7;
  RSetLastErr (7, "Unexpected error",userData ); /* Sets the current error status */
  string desc;
  int reUserData;
  RGetLastErr(desc,reUserData); /* Returns the last error */
  DebugN("Error returned:", desc, " ", reUserData);
}

Assignment

R Functions

Availability

R Control Extension

See also

RGetLastErr()