Skip to content

Fix Issue #75: Catch TypeError in marshalling #76

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

Merged
merged 1 commit into from
May 29, 2020

Conversation

robyoung
Copy link
Contributor

@robyoung robyoung commented Mar 9, 2020

When marshalling receiving a MarshallingError is much more useful than
receiving the underlying exception directly as the MarshallingError
has context about where it happened and it means all marshalling issues
can be handled in one place.

This change also catches TypeErrors from the int and float formatters
so that they are correctly turned into MarshallingErrors.

See: #75

@j5awry
Copy link
Contributor

j5awry commented Mar 23, 2020

@robyoung, thank you for contributing to flask-restx. I don't see any tests added to ensure MarshallingError is being raised. Since coverage didn't seem to go down, it appears to be a hole in the coverage. Could you contribute tests to ensure that the correct error is being raised?

@codecov
Copy link

codecov bot commented May 16, 2020

Codecov Report

Merging #76 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master      #76   +/-   ##
=======================================
  Coverage   96.92%   96.92%           
=======================================
  Files          19       19           
  Lines        2696     2696           
=======================================
  Hits         2613     2613           
  Misses         83       83           
Impacted Files Coverage Δ
flask_restx/fields.py 96.59% <100.00%> (ø)

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 24adcbc...9db12d7. Read the comment docs.

When marshalling receiving a `MarshallingError` is much more useful than
receiving the underlying exception directly as the `MarshallingError`
has context about where it happened and it means all marshalling issues
can be handled in one place.

This change also catches `TypeError`s from the int and float formatters
so that they are correctly turned into `MarshallingError`s.
@robyoung
Copy link
Contributor Author

@j5awry sorry for the delay in this. I have rebased on master and added a couple of tests.

@robyoung
Copy link
Contributor Author

The drop in coverage makes no sense to me. This adds no new lines of code and adds tests to cover the new branches but the coverage reporter reports a drop in coverage on a completely different module. 🤔

@ziirish
Copy link
Contributor

ziirish commented May 16, 2020

No problem, codecov makes some early reports that don't reflect the whole test suite.
It has now updated its report and seem more consistent ;)

@robyoung
Copy link
Contributor Author

Is there anything else that needs to happen before this can be merged?

@j5awry j5awry merged commit c6b43ba into python-restx:master May 29, 2020
@robyoung robyoung deleted the issue-75 branch May 29, 2020 18:28
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.

3 participants