Prevent UnboundLocalError in test_build_error_handler