NATS4 custom errors.php
NATS typically uses very simple error messages to display messages. These error displays tend to be for support personnel, and thus do not contain much information relevant to you as a program owner and admin. NATS4 now offers customization of NATS's error handling and error messages through custom_errors.php
To use our custom errors script, you must first create a file in nats/ called custom_errors.php. This file can contain anything you may want to display to a surfer, affiliate, or admin; you can also record these errors if you choose.
Note: Please make sure you read this entire article before creating your own custom_errors.php script, including the last section-- Warnings and Recommendations.
You will be able to access the following PHP variables in your custom_errors.php script:
- $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 will not be able to use the error file and line number yourself. For additional security, all Too Much Media product's PHP files are encoded, and cannot be debugged by our end-users. For further assistance, please Submit a Support Ticket.
As custom_errors.php is a PHP script, you will have access to the full power of PHP, including PHP superglobal variables. As a result, you will be able to make your custom_errors.php script do essentially anything you want it to do.
Warnings and Recommendations
This script may not always run-- in the case of some errors or server crashes, this script may not execute. If there is a critical PHP component that is failing, for example, NATS will not run long enough to process the error.
If you are reporting your errors to a MySQL database and NATS has a problem with the MySQL server, there will be no way for custom_errors.php to report the error to the database.
WARNING: Too Much Media's company policy states that no insertions or modifications are allowed to be made to the NATS database. If you wish to log error information in a database, please be sure to create a separate database for your logs.
WARNING: Do NOT display sensitive data.
Disabling for specific IPs
If the custom error page is only meant for your surfers, you can turn on 2 configurations to disable the custom error page for specific IPs:
- $config['DISABLE_CUSTOM_ERRORS'] - set to any non empty value to disable the custom error page for everyone
- $config['CUSTOM_ERROR_IPS'] - this requires DISABLE_CUSTOM_ERRORS to be on. This should be an array of IPs. When set, NATS disable the custom error page for only these IPs rather than everyone.
Generally, you would only add your own IPs or your developer's IP to the CUSTOM_ERROR_IPS array so that they can see the default error page displayed by NATS which includes all of the above error variables. If your custom error page contains all of this information already, it might not make sense to disable it at all.