Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception output #329

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions colcon_core/executor/sequential.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import logging
import signal
import sys
import traceback

from colcon_core.executor import ExecutorExtensionPoint
from colcon_core.executor import OnError
Expand Down Expand Up @@ -68,10 +67,9 @@ def execute(self, args, jobs, *, on_error=OnError.interrupt): # noqa: D102
"run_until_complete '{name}' finished"
.format_map(locals()))
return signal.SIGINT
except Exception as e: # noqa: F841
exc = traceback.format_exc()
logger.error(
"Exception in job execution '{name}': {e}\n{exc}"
except Exception:
logger.exception(
"Exception in job execution '{name}'"
.format_map(locals()))
return 1
result = future.result()
Expand Down
8 changes: 3 additions & 5 deletions colcon_core/plugin_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# Licensed under the Apache License, Version 2.0

from collections import OrderedDict
import traceback

from colcon_core.entry_point import load_entry_points
from colcon_core.logging import colcon_logger
Expand Down Expand Up @@ -65,12 +64,11 @@ def _instantiate_extension(
"Skipping extension '{group_name}.{extension_name}': {e}"
.format_map(locals()))
extension_instance = None
except Exception as e: # noqa: F841
except Exception:
# catch exceptions raised in extension constructor
exc = traceback.format_exc()
logger.error(
logger.exception(
'Exception instantiating extension '
"'{group_name}.{extension_name}': {e}\n{exc}".format_map(locals()))
"'{group_name}.{extension_name}'".format_map(locals()))
extension_instance = None
if not unique_instance:
_extension_instances[extension_class] = extension_instance
Expand Down
30 changes: 12 additions & 18 deletions colcon_core/task/python/test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# Licensed under the Apache License, Version 2.0

import re
import traceback

from colcon_core.logging import colcon_logger
from colcon_core.plugin_system import get_first_line_doc
Expand All @@ -27,7 +26,6 @@ def add_arguments(self, *, parser): # noqa: D102
add_python_testing_step_arguments(parser)

async def test(self, *, additional_hooks=None): # noqa: D102
pkg = self.context.pkg
args = self.context.args

logger.info(
Expand All @@ -36,8 +34,8 @@ async def test(self, *, additional_hooks=None): # noqa: D102
try:
env = await get_command_environment(
'setup_py', args.build_base, self.context.dependencies)
except RuntimeError as e:
logger.error(str(e))
except RuntimeError:
logger.exception('Failed to get command environment')
return 1
setup_py_data = get_setup_data(self.context.pkg, env)

Expand All @@ -52,15 +50,13 @@ async def test(self, *, additional_hooks=None): # noqa: D102
1, "test() by extension '{key}'".format_map(locals()))
try:
matched = extension.match(self.context, env, setup_py_data)
except Exception as e: # noqa: F841
except Exception:
# catch exceptions raised in python testing step extension
exc = traceback.format_exc()
logger.error(
logger.exception(
'Exception in Python testing step extension '
"'{extension.STEP_TYPE}': {e}\n{exc}"
"'{extension.STEP_TYPE}'"
.format_map(locals()))
# skip failing extension, continue with next one
continue
return 1
if matched:
break
else:
Expand All @@ -73,12 +69,11 @@ async def test(self, *, additional_hooks=None): # noqa: D102
1, "test.step() by extension '{key}'".format_map(locals()))
try:
return await extension.step(self.context, env, setup_py_data)
except Exception as e: # noqa: F841
except Exception:
# catch exceptions raised in python testing step extension
exc = traceback.format_exc()
logger.error(
logger.exception(
'Exception in Python testing step extension '
"'{extension.STEP_TYPE}': {e}\n{exc}".format_map(locals()))
"'{extension.STEP_TYPE}'".format_map(locals()))
return 1


Expand Down Expand Up @@ -176,12 +171,11 @@ def add_python_testing_step_arguments(parser):
try:
retval = extension.add_arguments(parser=parser)
assert retval is None, 'add_arguments() should return None'
except Exception as e: # noqa: F841
except Exception:
# catch exceptions raised in package selection extension
exc = traceback.format_exc()
logger.error(
logger.exception(
'Exception in Python testing step extension '
"'{extension.STEP_TYPE}': {e}\n{exc}".format_map(locals()))
"'{extension.STEP_TYPE}'".format_map(locals()))
# skip failing extension, continue with next one


Expand Down