def scan():
    'Caller function that tries to scans the file and write the report.'
    spec_path = settings['spec_path']
    try:
        api_spec = load_config_file(spec_path)
    except FileNotFoundError as e:
        error_message = f'Could not find API spec file: {spec_path}. {str(e)}'
        logger.error(error_message)
        raise SystemExit(ExitCode.USAGE_ERROR)
    except EmptyConfigFileError as e:
        error_message = f'API spec file is empty. {str(e)}'
        logger.error(error_message)
        raise SystemExit(ExitCode.USAGE_ERROR)
    except yaml.YAMLError as e:
        error_message = 'Error loading specification file.'
        error_message = '{}\nPyYAML: {}'.format(error_message, str(e))
        logger.error(error_message)
        raise SystemExit(ExitCode.USAGE_ERROR)
    try:
        root_node = EndpointNode(api_spec)
        results = root_node.run()
    except (InvalidKeyError, KeyError, InvalidPythonCodeError) as e:
        error_message = 'Error loading API spec.'
        error_message = '{} {}'.format(error_message, str(e))
        logger.error(error_message)
        raise SystemExit(ExitCode.USAGE_ERROR)
    try:
        write_report(results)
    except (BadConfigurationError, InvalidPythonCodeError) as e:
        logger.error(e)
        raise SystemExit(ExitCode.USAGE_ERROR)
    session.exit()
Caller function that tries to scans the file and write the report.
def scan():
    
    spec_path = settings['spec_path']
    try:
        api_spec = load_config_file(spec_path)
    except FileNotFoundError as e:
        error_message = f'Could not find API spec file: {spec_path}. {str(e)}'
        logger.error(error_message)
        raise SystemExit(ExitCode.USAGE_ERROR)
    except EmptyConfigFileError as e:
        error_message = f'API spec file is empty. {str(e)}'
        logger.error(error_message)
        raise SystemExit(ExitCode.USAGE_ERROR)
    except yaml.YAMLError as e:
        error_message = 'Error loading specification file.'
        error_message = '{}\nPyYAML: {}'.format(error_message, str(e))
        logger.error(error_message)
        raise SystemExit(ExitCode.USAGE_ERROR)
    try:
        root_node = EndpointNode(api_spec)
        results = root_node.run()
    except (InvalidKeyError, KeyError, InvalidPythonCodeError) as e:
        error_message = 'Error loading API spec.'
        error_message = '{} {}'.format(error_message, str(e))
        logger.error(error_message)
        raise SystemExit(ExitCode.USAGE_ERROR)
    try:
        write_report(results)
    except (BadConfigurationError, InvalidPythonCodeError) as e:
        logger.error(e)
        raise SystemExit(ExitCode.USAGE_ERROR)
    session.exit()