Archive

Posts Tagged ‘error-handling’

PHP Custom Error Handler

Oct 5th, 2008

This is custom error handler in PHP. You can use your custom error handler for showing the error in you customized format, logging the error in a log file and for other reason.

<?php
//error handler function
function customError($errno, $errstr, $fileName, $lineNo)
{

switch ($errno) {

// fatal error. die it.
case E_USER_ERROR:
echo [...]

Forms Error Catching and Displaying in Symfony

Apr 8th, 2008

In actions.class.php page of symfony framework, you can catch errors and display those errors in template. Set errors in your action/method using:

<?php
if ($error) {
$this->getRequest()->setError(‘userName’, ‘The user Name field cannot be left blank’);
$this->getRequest()->setError(‘email’, ‘The Email field cannot be left blank’);
return false;
}
?>

Return false is important for returning to the same form, from where you get data for [...]

JavaScript Error Handling for Beginners

Mar 30th, 2007

Please, do not forget to read the small updates below on JavaScript debugging. Ya, that is important. Thanks!
First of all I will suggest moving to Firefox browser. There you will get JavaScript console
(Firefox: Tools->JavaScript Console) which is very useful for JavaScript debugging.
Old IE style error message box will not give the correct line number [...]