KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Runtime errors with ON ERR CALL command in compiled mode
PRODUCT: 4D | VERSION: 20 | PLATFORM: Mac & Win
Published On: February 12, 2024

Prior to 20R3, the ON ERR CALL command does not catch the following runtime errors in compiled mode:

  • Indice out of range

  • Type incompatible

  • Dereferencing a Null pointer

In 20R3, a behavior change was integrated so that the errors above are caught in both interpreted and compiled mode; so, if you encounter these uncaught errors in your compiled database, the simple fix is to upgrade to 20R3. However, if your database is running on the LTS track (a.k.a. a "dot" version), you will have to wait until v21 in order to get the same behavior with the ON ERR CALL command.

If you are a 4D Partner, you can download a v20R3 nightly build here: https://product-download.4d.com/?branch=All&flag=All&version_number=20+R3&platform=All&type=All&build=.


However, you can still handle these runtime errors even without using 4D's error handing system. These types of errors also highlight the importance of adding checks to ensure that the expected outcome is reached.
  • Indice out of range: use correct start and end index values in loops, add checks to ensure the index pointer is within range before accessing data in arrays, collections, selections, etc.

  • Type incompatible: always declare variables/parameters, insert checks with the Value type command when dealing with Variant parameters

  • Dereferencing a Null pointer: use the Is nil pointer command before dereferencing a pointer


You may also find the references below to be useful: