Handling errors is important!
09 10 12 - 23:25Still I see a lot of code from users where functions returning error status are called with the call statement. Or I see exceptions not being handled as well as function results not being verified if they are nil. There are some common error cases which developers like to forget:
- new picture raises exception for out of bounds (negative size!) or out of memory situations.
- folderitem.item() returns nil on missing permissions.
- SQLSelect returns nil recordset with SQL Syntax errors
- Picture.Open can raise an exception
- getting a value from a dictionary can raise a TypeMistmatchException, like for converting a window to a string.
Unfortunately we had a bug in adding the exception checks. DynaPDFMBS.CreateNewPDF is okay with passing nil for the folderitem. You do that in order to create a PDF file in memory. The 12.5pr1 DynaPDF plugin raises an exception as I added an unnecessary nil check there. You'll find an updated plugin in the Prerelease download folder to fix this.
No comments