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

Handle exceptions in Vardef client #75

Merged
merged 34 commits into from
Dec 13, 2024

Conversation

tilen1976
Copy link
Contributor

@tilen1976 tilen1976 commented Dec 12, 2024

Add exception class VardefClientException:

  • Response body as argument
  • Handles two formats of Json Problem:
    • Constraint violation (with list of violations)
    • Simple Json Problem
  • Returns clear exception message with status and detail/message
  • Method handles exceptions gracefully and returns default text for status/detail/messages
  • Add decorator method:
    • Handle exceptions in the background
    • Catch exceptions from Api and raise VardefClientException

Add decorator on Vardef methods

@tilen1976 tilen1976 marked this pull request as ready for review December 12, 2024 13:31
@tilen1976 tilen1976 requested a review from a team as a code owner December 12, 2024 13:31
Copy link
Member

@mmwinther mmwinther left a comment

Choose a reason for hiding this comment

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

Very elegant implementation and great test coverage 😄 I think there are a couple of things which could be simplified.

src/dapla_metadata/variable_definitions/exceptions.py Outdated Show resolved Hide resolved
src/dapla_metadata/variable_definitions/exceptions.py Outdated Show resolved Hide resolved
src/dapla_metadata/variable_definitions/exceptions.py Outdated Show resolved Hide resolved
src/dapla_metadata/variable_definitions/exceptions.py Outdated Show resolved Hide resolved
Copy link
Member

@mmwinther mmwinther left a comment

Choose a reason for hiding this comment

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

Nice work 👍

@tilen1976 tilen1976 merged commit 82a1353 into main Dec 13, 2024
12 of 13 checks passed
@tilen1976 tilen1976 deleted the feat/vardef-client-add-tests-exceptions branch December 13, 2024 09:13
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