Solved

PHP 5 Exception recovery

Posted on 2007-04-10
1
528 Views
Last Modified: 2010-08-05
Can you resume execution after an uncaught exception is picked up by the customized exception handler?

For example, in my error class:

set_exception_handler("userExceptionHandler");

If I have code that throws an exception which is not caught, userExceptionHandler() catches and handles it.  Can I recover from there?
0
Comment
Question by:Steve Bink
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 48

Accepted Solution

by:
hernst42 earned 500 total points
ID: 18887773
No, if the exception is handled by the global exception handler The script finish after that point. Example:

function myExceptionHandler (Exception $ex) { return true; }
set_exception_handler("myExceptionHandler");
throw new Exception("This should cause a fatal error and this message will be lost");
echo "Test";

'Test' is never printed.
0

Featured Post

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question