Author Topic: Error Handling  (Read 4808 times)

Melinda DePalma

  • Member
  • *
  • Posts: 179
    • Productive Computing
Error Handling
« on: April 02, 2010, 03:50:04 PM »
Typically a 0 is returned for a success and if something unexpected happens, a plug-in function will return a
result of !!ERROR!!. This makes it simple to check for errors. If a plug-in function does not return a 0 OR
returns !!ERROR!!, then immediately after call PCIM_GetLastError function for a detailed description of what the
exact error was.

We find that most developers run into issues due to a lack of error trapping. Please ensure that you properly
trap for errors in your solutions. Here are a few samples of how you can check for errors.

Example 1:
Set Variable [ $result = PCIM_SomePluginFunction( “a” ; “b” ) ]
If [ $result ≠ 0 ]
Show Custom Dialog [ “An error occurred: “ & PCIM_GetLastError ]
End If

Example 2:
Set Variable [ $result = PCIM_SomePluginFunction( “a” ; “b” ) ]
If [ $result = !!ERROR!! ]
Show Custom Dialog [ “An error occurred: “ & PCIM_GetLastError ]
End If

The PCIM_GetLastError( format ) function gives you the option to display the error description or error number.
If format parameter is empty such as PCIM_GetLastError or PCIM_GetLastError( “” ), then an English description
of the error will be returned. If the format parameter is set to “Number” such as PCIM_GetLastError( “Number” ), then an error number will be returned.