move error reporting code to index.php