def execute_task(testcase_id, job_type):
    'Run regression task and handle potential errors.'
    try:
        find_regression_range(testcase_id, job_type)
    except errors.BuildSetupError as error:
        testcase = data_handler.get_testcase_by_id(testcase_id)
        error_message = ('Build setup failed r%d' % error.revision)
        data_handler.update_testcase_comment(testcase, data_types.TaskState.ERROR, error_message)
        build_fail_wait = environment.get_value('FAIL_WAIT')
        tasks.add_task('regression', testcase_id, job_type, wait_time=build_fail_wait)
    except errors.BadBuildError:
        testcase = data_handler.get_testcase_by_id(testcase_id)
        testcase.regression = 'NA'
        error_message = 'Unable to recover from bad build'
        data_handler.update_testcase_comment(testcase, data_types.TaskState.ERROR, error_message)
Run regression task and handle potential errors.
def execute_task(testcase_id, job_type):
    
    try:
        find_regression_range(testcase_id, job_type)
    except errors.BuildSetupError as error:
        testcase = data_handler.get_testcase_by_id(testcase_id)
        error_message = ('Build setup failed r%d' % error.revision)
        data_handler.update_testcase_comment(testcase, data_types.TaskState.ERROR, error_message)
        build_fail_wait = environment.get_value('FAIL_WAIT')
        tasks.add_task('regression', testcase_id, job_type, wait_time=build_fail_wait)
    except errors.BadBuildError:
        testcase = data_handler.get_testcase_by_id(testcase_id)
        testcase.regression = 'NA'
        error_message = 'Unable to recover from bad build'
        data_handler.update_testcase_comment(testcase, data_types.TaskState.ERROR, error_message)