Skip to content

v2.1.x Chore - Document exception nomenclature #387

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

Open
coderabbitai bot opened this issue May 1, 2025 · 0 comments
Open

v2.1.x Chore - Document exception nomenclature #387

coderabbitai bot opened this issue May 1, 2025 · 0 comments
Labels
Chore Miscellaneous chores to maintain the project documentation Improvements or additions to documentation good first issue Good for newcomers

Comments

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 1, 2025

Background

There is a consistent pattern of using _cause as the variable name when catching exceptions for chaining in the codebase, but this convention is not documented in the Exception Guide.

Proposed Change

Add the following section to the "Error Handling Practices" section of the Exception_Guide.md:

- **Exception Variable Naming**: When catching exceptions for re-raising or chaining, use `_cause` as the standard variable name. This follows PEP 8's convention for variables that might appear unused while clearly indicating the variable's purpose in exception chaining.
  # Good practice
  try:
      some_operation()
  except SomeError as _cause:
      raise CustomError("Meaningful message") from _cause

Motivation

Documenting this convention will:

  • Promote consistency across the codebase
  • Provide clear guidance for new contributors
  • Make the reason for the naming convention explicit

Related to PR #385 discussion: #385 (comment)

Assignee

@reactive-firewall

@reactive-firewall reactive-firewall added documentation Improvements or additions to documentation good first issue Good for newcomers labels May 2, 2025
@reactive-firewall reactive-firewall added the Chore Miscellaneous chores to maintain the project label Jun 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Chore Miscellaneous chores to maintain the project documentation Improvements or additions to documentation good first issue Good for newcomers
Projects
Status: To do
Development

No branches or pull requests

1 participant