Implement an error_handler callback for phps built in set_error_handler. It basically throw a proper exception.