Error handling
When something unexpected happens, the plug-in will pop up a dialog showing what the error message is. This makes it easy to see what went wrong.
However, in some cases, you may prefer to show your own message to the user, or possibly not show a message at all.
In that case, you can call <<setErrorCaptureFunctionName>>
with a parameter of true. That will suppress the error dialog from appearing to the user.
When you call this function, it is set for that plug-in for as long as FileMaker is running, so if you want to do all of your own error handling,
you can just set it to true once in your startup script. However, we recommend only turning it on when your script is prepared to check for errors, and then turning it off after finishing that section.
Whether or not you suppress the error dialogs, a plugin function will return the word ERROR
if something goes wrong. It's a good idea to put your plugin functions in an 'If' statement so that you don't execute a bunch of script steps after something has gone wrong. If you'd like for your script to get the error message, you can get that by calling the <<lastErrorFunctionName>>
function.
Here is an example of basic error reporting:
Set Variable [ $result: Value: MyPluginFunction("x" ; "y" ; "z") ] If [ $result = "ERROR" ] Show Custom Dialog [ "Error occurred: " & <<lastErrorFunctionName>> ] Exit Script Else do more stuff here ... End If
Chaining Multiple Functions Together
Since the string "ERROR"
evaluates to false when evaluated by FileMaker, and most plugin functions return a 1
when successful, you can chain multiple dependent plugin operations together using the "and"
operator.
However, in this case the result will be a 1
or a 0
, not "ERROR"
. For example: if any of the functions fail, the calculation will
short-circuit with a result of false
and none of the subsequent function calls will be evaluated.
Set Variable [ $success= FirstPluginFunction("x") and SecondPluginFunction("y") and ThirdPluginFunction("z") ] If [not $success] Show Custom Dialog [ "An error occurred: " & <<lastErrorFunctionName>> ] End If
Note: the above only works for plugin functions which return 1
on success! Check the documentation for each function used in this manner.
Additional Error Checking - Plugin not installed
If a plugin is not installed correctly, calls to a plugin function will return "?". As part of your startup script, you should check for this occurrence and display a warning accordingly that the plugin needs to be installed. Note: when treated as a boolean true/false value, FileMaker will treat ?
as true
.