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

Better exception classes #89

Merged
merged 7 commits into from
Sep 28, 2021
Merged

Better exception classes #89

merged 7 commits into from
Sep 28, 2021

Conversation

dchiquito
Copy link
Contributor

@dchiquito dchiquito commented Sep 27, 2021

I had some difficulty parsing the exceptions being thrown now that I need to differentiate between pydantic and jsonschema validation errors. This PR should mitigate that pain a bit.

Not a blocker, but nice to have in the future.

There are now two different exceptions, `JsonschemaValidationError` and
`PydanticValidationError`, to better communicate the difference between
the two validation modes.

This makes it much easier to consume errors, since the two validators
produce errors in vastly different shapes.
I don't see a purpose to wrapping the exception in a list, and it makes
consuming the error more difficult.
@dchiquito dchiquito added enhancement New feature or request patch Increment the patch version when merged labels Sep 27, 2021
@dchiquito dchiquito requested a review from satra September 27, 2021 16:43
@codecov
Copy link

codecov bot commented Sep 27, 2021

Codecov Report

Merging #89 (b4c199e) into master (d4c1378) will increase coverage by 5.48%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #89      +/-   ##
==========================================
+ Coverage   89.47%   94.96%   +5.48%     
==========================================
  Files          14       16       +2     
  Lines        1378     1490     +112     
==========================================
+ Hits         1233     1415     +182     
+ Misses        145       75      -70     
Flag Coverage Δ
unittests 94.96% <100.00%> (+5.48%) ⬆️

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

Impacted Files Coverage Δ
dandischema/exceptions.py 100.00% <100.00%> (ø)
dandischema/metadata.py 96.90% <100.00%> (ø)
dandischema/tests/test_metadata.py 100.00% <100.00%> (ø)
dandischema/tests/conftest.py 100.00% <0.00%> (ø)
dandischema/tests/utils.py 100.00% <0.00%> (ø)
dandischema/tests/test_datacite.py 82.70% <0.00%> (+36.19%) ⬆️
dandischema/datacite.py 95.32% <0.00%> (+43.92%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d4c1378...b4c199e. Read the comment docs.

Copy link
Member

@yarikoptic yarikoptic left a comment

Choose a reason for hiding this comment

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

approve in general, thank you! might be worth tuning up test just a bit

@@ -113,9 +113,9 @@ def _validate_obj_json(data, schema, missing_ok=False):
for error in sorted(validator.iter_errors(data), key=str):
if missing_ok and "is a required property" in error.message:
continue
error_list.append([error])
error_list.append(error)
Copy link
Member

Choose a reason for hiding this comment

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

yikes, thank you @dchiquito

@yarikoptic
Copy link
Member

thank you @dchiquito , looks kosher to me, so let's proceed... and let's release right away

@yarikoptic yarikoptic added the release Create a release when this pr is merged label Sep 28, 2021
@yarikoptic yarikoptic merged commit d423c93 into master Sep 28, 2021
@yarikoptic yarikoptic deleted the enh-exceptions branch September 28, 2021 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request patch Increment the patch version when merged release Create a release when this pr is merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants