NATS3 custom errors.php
Applies to NATS 22.214.171.124 and greater.
NATS has normally displays errors in the form of a very simple error message. This error is for support personnel and does not contain much information for you as a program owner and administrator, but now you can use custom_errors.php to customize how NATS's error handling.
The following example shows an error in the standard format.
Create a file in nats/includes/ called custom_errors.php. This file may contain anything you want to both display an error message to the surfer, affiliate, or admin and also to record this error. Before creating your own custom_errors.php script, please read this entire article, including the last section, Warnings and Recommendations. You have access to the following PHP variables in custom_errors.php:
- $errstr - This variable contains the actual text of the error message.
- $errfile - This variable contains the file from which the error was encountered.
- $errline - This variable contains the line number of the file contained in $errfile.
Note: You can't use the error file and line number yourself. All Too Much Media product PHP files are encoded and cannot be debugged by end-users.
This example is fairly simplistic -- it reports the standard error code text, logs this error message to a custom database and table, and finally provides the user with a link to manually report the error message to the program owner. Navigation links were also included at the bottom of the page to go back one page in history and return to the main program page.
Since this is a PHP script, you have access to all of the PHP "superglobal" variables and the full power of PHP. You can make your custom_errors.php script do pretty much anything you want it to do.
Warnings and Recommendations
This script will not always run; in some errors or server crashes, this script may not execute. If there is a critical PHP component that's failing, for example, NATS won't run long enough to process the error.
If you're reporting your errors to a MySQL database and NATS has a problem with the MySQL server, there is no way for custom_errors.php to report the error to the database.
WARNING: do not use the NATS database to log errors. If you're reporting your errors to a MySQL database, create separate database You'll note that in Figure 1.3, the database username, password, and host information is stored in plain text; if you use the NATS database login information or that of any other secure database, you risk exposing your login information to the public. If this script modifies the content of the NATS database table structure or data content, we will not be able fix your problems.
WARNING: do not display sensitive data.