PA_GetLastError

4D - Documentation   Français   English   German   4D Plugin API, Command Theme List   4D Plugin API, Command Alphabetical List   Back   Previous   Next

version 2003


PA_GetLastError lastError

ParameterTypeDescription
This command does not require any parameters
Function resultlastErrorThe last error that occured

Description

The routine PA_GetLastError returns the error code of the most recent error coming from a 4D PluginAPI routine call.

Almost every API routine can generate an error code, however some always return 0 (eER_NoErr).

Error codes are listed in the header file PublicTypes.h and in this documentation, see PA_ErrorCode

eER_NoErr means no error, its value is 0.

It is a good habit to always call PA_GetLastError after a call to any API routine to check if a problem occurred.

NOTE

When called, PA_GetLastError does not reset the last error.

Example

Allocating and initializing a PA_Handle.

   Somewhere in a header file:
   typedef struct{
      long   magicNumber;
      long   dataSize;
      char   data[1];
   } MyStruct, *MyStructPtr, **MyStructHdle;

   MyStructHdle NewMyStructHandle()
   {
      short   err = eER_NoErr;
      MyStructHdle   h;
   // Allocate the handle
      h = (MyStructHdle) PA_NewHandle(sizeof(MyStruct));
   // Check the error
      err = PA_GetLastError();
      if(!err)
      {
      // OK, the handle was allocated. We can initialize it.
         (*h)->magicNumber = 'TITI';
         (*h)->dataSize = 1;
         (*h)->data[0] = 0;
      }

      return h;
   }

See Also

PA_ErrorCode.

Error Handling

Since this is the routine for error handling, it does not generate any error itself.


4D - Documentation   Français   English   German   4D Plugin API, Command Theme List   4D Plugin API, Command Alphabetical List   Back   Previous   Next