Seting youyr own custom Error messages instead of getting generic error messages!
Page 1 of 1
Seting youyr own custom Error messages instead of getting generic error messages!
- Code:
<?php
function myErrorHandler() {
echo " ";
}
// this will return nothing instead of an error, this can be customised to send an email or
//log to a logfile.txt or display an error of your choosing!
?>
Usage code is below
<?php
set_error_handler("myErrorHandler");
try {
include "somefile.php";
} catch (Exception $e) {
echo $e->getMessages();
}
?>
- Code:
Example 2:
<?php
function myErrorHandler($eNum, $eMsg, $errFile, $errLine) {
throw new ErrorException($errMsg, $errNum, 0, $errFile, $errLine);
}
// this will return nothing instead of an error, this can be customised to send an email or
//log to a logfile.txt or display an error of your choosing!
?>
Usage code is below
<?php
set_error_handler("myErrorHandler");
try {
include "somefile.php";
} catch (Exception $e) {
echo "<b>", $e->getMessages(), "</b>";
}
// you could also use $e->getTraceAsString(),
?>
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum