error — get/set the RSP error message


string error( message);  
string   message ;


RSP has a simple error handling system. Some functions and methods are capable of running into error conditions in which case they set the RSP last error message accordingly. If an RSP function returns an error value then you can use this function to get a message describing the most recent error that occured.

You can also set the RSP last error message yourself by providing the optional parameter message. If this parameter is present then the last error message is assigned this new value, which is then returned. An empty string "" represents no error.

Example 33. error Example

// A contrived example of a function which performs division safely
int divide(int a, int b)
    if(b == 0)
        error("Divide by zero");
        return 0;
        return a / b;

// Reset the error before calling it, otherwise there's no way of being
// sure that a zero return value is an error.
int result = divide(10, 0);
if(result == 0 && error() != "")
    print("<p>Error: " + error() + "</p>\n");