Jump to content

[SOLVED] Customize error message?


djfox

Recommended Posts

It depends on how you want to "customize it"

 

In a production enviroment it is not good to display real errors to users.

 

In a case like that I would create my own function called "errorReport" or something similiar. This would email the admin the error and then display a friendly message like this:

 

function errorReport($msg, $mysql=false) {
    if ($mysql) {
        $msg .= " MySQL Error: " . mysql_error();
    }

    mail(ADMIN_EMAIL, "Error", $msg, HEADERS); // note ADMIN_EMAIL and HEADERS are constants that need to be defined.

    die("An error has occurred, the admin has been emailed. We apologize for this issue.");
}

 

That way you know about the error and the user is displayed a nice message letting them know about the error.

 

That is how I handle it (well in a similiar fashion just more robust).

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.