use restore_error_handler instead of set_error_handler($previous)