The dberror event on the DataWindow control or DataStore object will be triggered. Recent versions have a dberror event on the transaction object.
You could add any line of code and put a debug stop on it. Better yet add code to record to an error log and display the error in a window or MessageBox.
The dberror event is triggered even if the DW/DS dberror event has code so don't try to display/record in both places.
The error code and description are passed as arguments to the dberror event.