Capturing Vortex Errors

 

If the Vortex function putmsg is defined in a script, it will be called when errors occur, instead of the errors being printed out and logged. The following variables are set when putmsg is called:

  • $errnum   A number indicating the severity and type of the error. There are several classes of errors:

    • 000-099 Errors

    • 100-199 Warnings

    • 200-299 Informational messages

    • 300+ Miscellaneous/debug messages
    Note that the error number is to be used to classify the error (e.g. whether to display it or not); it does not uniquely identify the specific error message.

  • $errscript   The URL path of the Vortex script, or the module name in square brackets, where the error occurred.

  • $errline   The source line in the script or module where the error occurred.

  • $errmsg   A text message describing the error.

  • $errfunc   The C (not Vortex) function where the error occurred; empty ("") if unknown. This is useful for technical support.

  • $errvfunc   The Vortex function where the error occurred; empty if unknown.

  • $errpid  

    The process ID of the Vortex process where the error occurred, as an int.

  • $errthreadname  

    The name of the thread where the error occurred; empty if unknown.

  • $errthreadid  

    The thread ID where the error occurred, as an int.

  • $errtime  

    The time when the error occurred, as a double.

These variables may have several values, if more than one error occurrs at a time. The variables are reset each time putmsg is called. The $errpid, $errthreadname, $errthreadid, $errtime variables were added in version 7.07.1568658000 20190916.

This example putmsg function just saves all the messages until another function is called to print them out:

<A NAME=putmsg PRIVATE>
  <$savnum = $savnum $errnum>
  <$savmsg = $savmsg $errmsg>
  <$savline = $savline $errline>
</A>

The following function can then be called at an appropriate point to print out the errors, such as at the end of the script, or after a <TABLE> has been completed:

<A NAME=flushmsg PRIVATE>
  <LOOP $savnum $savmsg $savline>
    <SWITCH $savnum>
      <CASE lt 100>
        <B>Error</B>:
      <CASE lt 200>
        <B>Warning</B>:
      <CASE lt 300>
        Note:
    </SWITCH>
    At line $savline: $savmsg <BR>
  </LOOP>
  <$savnum = >  <$savmsg = >  <$savline = >
</A>

By caching the messages, errors can be kept from breaking up the script's desired HTML output, yet still be printed to the user if desired. Or certain errors can be ignored altogether, such as when fetching pages from a site that might be down.


Copyright © Thunderstone Software     Last updated: Sep 25 2019
Copyright © 2019 Thunderstone Software LLC. All rights reserved.