-3

Is there any way how to enrich error messages in php? I'm getting errors like

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 524288 bytes) in /site/lib/Zend/Db/Statement/Pdo.php on line 228

which is not quite good. At least callstack would be more helpful.

Jaro
  • 3,799
  • 5
  • 31
  • 47
  • 3
    What's not clear to you in this error? it's actually very clear. Your program is using more RAM than it is allowed to and has no more RAM left to use. Allocate more memory to it. – Benjamin Gruenbaum Mar 13 '13 at 14:20
  • I think that error message is very clear and to the point. Should it say "Oops, my deary, you are trying to have too much memory. There There try again later. Sorry about that.". Just deal with it. Either make the script less memory intensive or enable it to have more memory. – Ed Heal Mar 13 '13 at 14:24
  • You are be able to get the callstack... Tried searching @ php.net? debug_backtrace http://php.net/manual/en/function.debug-backtrace.php Other way of good information is create your own ExceptionHandlers... Example over here: http://www.edmondscommerce.co.uk/php/php-custom-error-and-exception-handler-make-php-stricter/ – eL-Prova Mar 13 '13 at 14:21

3 Answers3

1

If you want more detailed information then there is a way to intercept the error message in a function. In there you could throw an ErrorException for exmaple. That would give you more details.

Try something like the following (the catchException is optoinal though)

function exception_error_handler($errno, $errstr, $errfile, $errline )
{
    if (error_reporting() === 0)
    {
        return;
    }

    throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}

set_error_handler("exception_error_handler");

function catchException($e)
{
    // Do some stuff
}

set_exception_handler('catchException');
w00
  • 26,172
  • 30
  • 101
  • 147
0

Try installing xdebug, take a look at the various settings ...

Cups
  • 6,901
  • 3
  • 26
  • 30
-1

Well PHP errors are very clear to me but if you want very detailed info why dont you write exception class and have custom messages including the exception message and your own details.

GGio
  • 7,563
  • 11
  • 44
  • 81