| Home | Previous Lesson: The cb_Save_to_Log CommandButton Next Lesson: Events and Messages |
Test error handling script written to the SystemError event by using the SignalError() function. Simply assign some values for the 'error' object and call the function. This causes an application level 'SystemError' event to be triggered, allowing you to review and test your application's error handling.
To see how this works, write the following script in the 'rButtonDown' event for one of the CommandButtons:
// Object: cb_query for window w_product_master
// Event: rbuttondown
//
// This is test code which enables you to
// test the error information window
//
error.object = "window"
error.text = "This is an error"
error.line = 10
SignalError()
This simply assigns some values to the error object and calls the SignalError() function. When you run the application, right-click on this button and the error Information window will be displayed with the values assigned to the error object. Once you run this code and see the results, remove the above code.
From version 6.0 onwards, you can specify error number and error text as arguments to the SignalError() function. PowerBuilder automatically populates other information in the error object and signals 'SystemError' event. Arguments to SignalError() are optional. If you don't specify arguments, you need to take care of populating all the values in the 'error' object, even though it is not mandatory to populate all the attributes in 'error' object.
A new function was introduced with 6.0, PopulateError(). It takes same arguments as SignalError() takes, however, arguments to this function are mandatory. This function just populates the 'error' object. It doesn't trigger the 'SystemError' event. This feature allows you to populate the 'error' object at certain point of time and trigger the SystemError event at another place.
| Home | Previous Lesson: The cb_Save_to_Log CommandButton Next Lesson: Events and Messages |