Skip to content

v2.1.x Chore - Refactor exception logging #386

Open
@coderabbitai

Description

@coderabbitai

Description

This issue tracks the refactoring of redundant exception logging instances throughout the codebase.

Problem

Several places in the codebase use redundant exception objects in logging.exception() calls. Since logging.exception() already automatically includes the exception traceback and message, passing the exception string explicitly is redundant.

Example:

except Exception as _cause:  # pragma: no branch
    _LOGGER.debug(str(type(_cause)))
    _LOGGER.exception(str(_cause))  # Redundant - exception already included
    _LOGGER.debug(str((_cause.args)))

Recommended Fix

Replace redundant exception logging with a descriptive message:

except Exception as _cause:  # pragma: no branch
    _LOGGER.debug(str(type(_cause)))
    _LOGGER.exception("Exception occurred while processing")  # Better
    _LOGGER.debug(str((_cause.args)))

Or, if no additional context is needed:

except Exception as _cause:  # pragma: no branch
    _LOGGER.debug(str(type(_cause)))
    _LOGGER.exception("")  # Let the exception details speak for themselves
    _LOGGER.debug(str((_cause.args)))

Files to Refactor

  • tests/__init__.py: Line ~197
  • [Add additional instances found during implementation]

Related

Metadata

Metadata

Labels

ChoreMiscellaneous chores to maintain the projectPython LangChanges to Python source code

Type

Projects

Status

To do

Relationships

None yet

Development

No branches or pull requests

Issue actions