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

Refactor exceptions to have a common base class (PP-991) #1695

Merged
merged 9 commits into from
Feb 26, 2024

Conversation

jonathangreen
Copy link
Member

Description

Rename BaseError to be BasePalaceException. Refactor this class to remove the inner exception parameter, since Python 3 has exception chaining. Then refactor all the exceptions defined in our codebase to all have this as a base class, so its easier to catch all of our exceptions if we need to.

Motivation and Context

Follow up to the work in #1694 which gave all our exceptions that return problem details a common base class.

How Has This Been Tested?

  • Running tests

Checklist

  • I have updated the documentation accordingly.
  • All new and existing tests passed.

Copy link

codecov bot commented Feb 23, 2024

Codecov Report

Attention: Patch coverage is 96.55172% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 90.21%. Comparing base (67bab4e) to head (2ae712e).

Files Patch % Lines
api/saml/metadata/parser.py 60.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1695   +/-   ##
=======================================
  Coverage   90.21%   90.21%           
=======================================
  Files         245      245           
  Lines       28188    28199   +11     
  Branches     6447     6447           
=======================================
+ Hits        25429    25441   +12     
+ Misses       1823     1822    -1     
  Partials      936      936           
Flag Coverage Δ
Api 75.98% <89.65%> (+<0.01%) ⬆️
Core 59.84% <67.24%> (+0.01%) ⬆️
migration 26.96% <46.42%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jonathangreen jonathangreen requested a review from a team February 26, 2024 16:27
Copy link
Contributor

@dbernstein dbernstein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple of minor things: feel free to merge once those are resolved.

def __init__(
self, message: str | None = None, inner_exception: Exception | None = None
):
def __init__(self, message: str | None = None):
"""Initializes a new instance of BaseError class
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BaseError -> BasePalaceException

"""Initializes a new instance of BaseError class

:param message: String containing description of the error occurred
:param inner_exception: (Optional) Inner exception
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error -> exception that

And the inner_exception has gone away yes?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, inner_exception was removed. Its leftover from Python 2 days when there was no built in way to chain exceptions. Now that we are on Python 3 I replaced it with PEP3134 exception chaining in the couple places where inner_exception was previously used.

Base automatically changed from feature/refactor-circulation-exceptions to main February 26, 2024 23:02
@jonathangreen jonathangreen force-pushed the feature/more-exception-refactoring branch from 98e672b to 2ae712e Compare February 26, 2024 23:20
@jonathangreen
Copy link
Member Author

@dbernstein I made the changes from mentioned in your code review comments. I can't merge though until you approve the PR review.

@jonathangreen jonathangreen merged commit 822723a into main Feb 26, 2024
28 checks passed
@jonathangreen jonathangreen deleted the feature/more-exception-refactoring branch February 26, 2024 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants