What is the best method to handle errors?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fastfingertips
Forum Contributor
Posts: 242
Joined: Sun Dec 28, 2003 1:40 am
Contact:

What is the best method to handle errors?

Post by fastfingertips »

I have designed an error function that is managing my errors but I would like to know if is there any other method, a better one.

Code: Select all

<?php

function myErrorHandler ($errno, $errstr, $errfile, $errline)
{
//My-SQL errors
$Error_Codes[1]="This is an error";
?>
<HTML>
  <HEAD>
  </HEAD>
  <BODY>
    <table>
      <tr>
        <td>
          <font class="title"><b><? echo $Error_Codes[$errstr];?><br>
        </td>
      </tr>
    </table>
  </BODY>
</HTML>
<?
exit();
}
error_reporting  (E_ERROR);
$old_error_handler = set_error_handler("myErrorHandler");


?>
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post by Nay »

I'm not sure but from what I've heard the more common approach is to redirect the user to a "Sorry, there seems to been an error bla bla bla contact webmaster bla bla bla" and log the error that happened. On log, e-mail the webmaster.

-Nay
Post Reply