When writing a plug-in you should use PA_GetLastError in several places in your code. The reason for this is that most API calls in 4D will return an error code, or will return eER_NoErr, which is equal to zero. By using PA_GetLastError you can check if your code is functioning correctly and trap any errors that occur. For a list of the Error Codes please review the "4D Plug-in API Reference" document on page 733. Most commands listed in the API Reference will also inform you of what type of error is returned for the call in the section called "Error Handling".
For example, let's say we are initializing and allocating a PA_Handle. Notice how we are checking the error returned from the call to PA_NewHandle. If the handle is created without any problems we can then initialize it.
} MyStruct, *MyStructPtr, **MyStructHdle;
short err = eER_NoErr;
// Allocate the handle
h = (MyStructHdle) PA_NewHandle(sizeof(MyStruct));
// Check the error
err = PA_GetLastError();
// OK, the handle was allocated. We can initialize it.
(*h)->magicNumber = 'TITI';
(*h)->dataSize = 1;
(*h)->data = 0;
Note: This example was taken from the "4D Plug-in API Reference" document on page 245.