« A few more pictures f… | Home | New MBS REALbasic Plu… »

Tip of the day: DynaPDF Error event

With our DynaPDF plugin you can create, modify and import PDF files. The plugin is very powerful, but you should have correct error handling in your application.

For error handling, we have an Error event. There you can get the type, code and message for the error. And you can decide whether your app should continue or stop. As you get warnings and errors here, you should at least have some code to decide this. Most apps want to inform the user about warnings, but allow continue after the warning. While on an error you may want to stop or continue. This depends on the error.

You can find some sample code for the error event in our Create PDF example project. As you see there, we show a message dialog and ask the user whether he wants to continue or not. Also we allow to ignore all warnings.

Now you can improve your code by using special error handling. For example before you load a new font, you could load a standard font (like Helvetica) with the same style. If your new font fails to load and you ignore the error, you can still write text with the default font you loaded before.

Another way to handle errors are exceptions. We had a lot of users not using the error event. And they complained about things that did not work. If you set a font with an invalid font name and you ignore all errors, you will see no text (if you didn't set a font successfully before). To help those users we introduced code to raise an exception for any unhandled error. So you know about that an error happened even if you forgot to use the error event. But the exception way does not allow you to continue after an error or warning. So better use the error event. Claris FileMaker Plugin
18 10 10 - 12:50