August 14, 2014 at 3:34 pm #780
I understand that suneido provides throw and AlertError for error handling. Throw is more useful for debugging which is aimed for developers alike and AlertError is more user friendly for ordinary users. So I would like to use AlertError but it seems that it does not stop code execution. Is that the case or have i misunderstood something? Is there any option to show error message and stop any further code execution at once?
Furthermore, I would also like to rollback all database changes whenever an error message is encountered. Is that possible? Or do I have to handle database rolling back inside of a transaction always?August 14, 2014 at 4:06 pm #1070amckinlayKeymaster
AlertError is just an Alert (MessageBox) with an “error” icon. It is not intended to stop execution.
In a GUI program, “stopping” is not quite the same as in straight procedural code. e.g. if you are in a button handler, you can just return to not do anything further for that button press.
To roll back database changes, you need to be inside a transaction. (And database changes must be specifically associated with that transaction in order to be rolled back.)
If you use the “block” form of Transaction and the code throws an exception, then the transaction is automatically aborted and the changes rolled back.
I hope that helps.August 15, 2014 at 3:35 am #1071
Thanks for your help indeed.
Alter: I had a look into your accounting application and you are right. Using Alter followed by Return seems to stop going further. But I am concerned that in the case which more than one functions are invoked, while the fist might be stopped, the others will still be called after the first. Is this the only way to go for now?
Throw: I notice that using throw without try/catch does stop code execution. But I am cautious and try not to show the debug window to end users. In the past, I had some painful experiences even if the error message is short and sweet. That debug window is nice for developers but is likely to drive the users mad at me 🙂 .
Thanks for the tips regarding database rollbak. I will keep that in mind.August 15, 2014 at 6:10 pm #1072amckinlayKeymaster
If Suneido.User is set to something different than “default” then the debugger will not be displayed. A more user friendly message is shown.August 18, 2014 at 1:19 am #1073
Nice, thanks for pointing that out Andrew.
- You must be logged in to reply to this topic.