I need to implement an atexit
Python function that would get the last error object and check for it's type. If the type of python error corresponds to PHP's E_ERROR
I should save the error's output to a file.
The PHP code I'm porting looks like so:
register_shutdown_function( "fatal_handler" );
function fatal_handler() {
$error = error_get_last();
if ($error != null && $error['type'] === E_ERROR)
echo "recordFatalError: {$error['message']}\n";
}
My code snap are as follows:
def fatal_handler():
# How to get last error object?
atexit.register(fatal_handler)
I would be glad if somebody explained me how can I get the necessary functionality with python.