Skip to content

Handling errors inside shutdown functions

by Jonathon on July 14th, 2009

Using register_shutdown_function() to do stuff on script shutdown requires special error handling. Normal error handling does not work within the function called, so if an error occurs inside your shutdown function you get this nondescript error:

Fatal error: Exception thrown without a stack frame in Unknown on line 0

The solution was to catch the exception and call the exception handler directly:

function shutdown_handler() {

	try {
		//... do stuff
	}
	catch(Exception $e) {
		die($e);
	}

}

From → Notebook

No comments yet

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS