See Also: String Functions, Lowercase, Explanation of user (handled) errors and unhandled errors, AddUserError, CallStackDump
A global procedure used to generate a user error.
None
Use DfError.pkg
Send UserError {Error Message} {Error Caption}
Where:
{Error Message} is a string containing the error message text to be displayed
{Error Caption} is a string containing the text to be displayed on the message box caption bar
The UserError global procedure can be use to generate a user error. A message box will be presented with the text of {Error Message} and a caption of {Error Caption}.
Send UserError "Insufficient Inventory Stock" "Validation Error"
If {Error Caption} is an empty string, the value of the ErrorSystem object’s psUserErrorCaption will be used. The following sample will display "Error" as the caption.
Send UserError "Insufficient Inventory Stock" ""
UserError provides a simple and consistent way to present users with error messages.
Function Validate_Save Returns Integer
Integer iRetVal
Forward Get Validate_Save To iRetVal
If iRetVal Function_Return iRetVal
If (Invt.On_Hand < 0) Begin
Send UserError "Insufficient Inventory Stock" ""
Function_Return 1
End
End_Function
The UserError method generates an actual error by using the Error command. This means that it has the "lock-safe" deferral mechanism built into the error handler. If UserError is sent within a database transaction (i.e., a locked state), the reporting of the error is deferred until the transaction is rolled back and the database is unlocked. It is recommended that you use UserError or the error command to generate user errors and to not use the message box interface. This ensures that a message box is never displayed in a locked state.
The text provided in {Error Message} can be long and therefore descriptive. In Windows applications, forced line breaks can be added to a message by using inserting the "\n" marker in your text stream.
Send UserError ("Insufficient Inventory Stock\n\n" + ;
"Your order exceeds the inventory stock of this item by" * ;
String(-Invt.On_Hand) * “items.\n" + ;
"You should either change the order quantity or cancel it.") ;
"Error in Processing Order"
In Web applications, forced line breaks can be added to a message by using inserting the "\n\r" marker in your text stream.
Send UserError ("Insufficient Inventory Stock\n\r\n\r" + ;
"Your order exceeds the inventory stock of this item by" * ;
String(-Invt.On_Hand) * “items.\n\r" + ;
"You should either change the order quantity or cancel it.") ;
"Error in Processing Order"
Determine if your application makes meaningful use of error numbers when reporting user errors to users. If they do not, use the UserError procedure to generate these errors.
When creating error support in an application, determine if an error condition is a user error or an unhandled error. If the error is a user error, use the UserError procedure to report the error. If the error is unhandled, use the Error command to generate the error.
Do not use the message box interface to generate errors. It is not "lock-safe", meaning that if a message box pops up during a lock, the lock will stay in place until the user interacts with the message box.
Make your error messages descriptive.