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

[request] Clearer error message for JSON deserialization failure #2195

Merged
merged 5 commits into from Aug 6, 2018

Conversation

Projects
None yet
3 participants
@codeclown
Copy link
Contributor

codeclown commented Jul 22, 2018

Description

Currently, when response JSON is not parsed successfully and an error is raised, the error message only contains the response body.

Motivation and Context

This is unnecessarily cryptic. As someone using the new request implementation for the first time, I was confused as to why just an error "foo" was raised when I was testing a new endpoint.

How Has This Been Tested?

Relevant test updated.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation change

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have updated docs/change-log.md
@spacejack

This comment has been minimized.

Copy link
Contributor

spacejack commented Jul 23, 2018

Couple of comments:

You can add your own deserialize hook in the RequestOptions object, and try/catch/throw the JSON parse error there.

If we do want to make this change, Mithril's codebase is ES5 so the template string should be changed to use ES5 string concatination.

@codeclown

This comment has been minimized.

Copy link
Contributor

codeclown commented Jul 23, 2018

@spacejack

You can add your own deserialize hook in the RequestOptions object, and try/catch/throw the JSON parse error there.

Sure, but I don't see a reason not to throw useful errors out-of-the-box.

If we do want to make this change, Mithril's codebase is ES5 so the template string should be changed to use ES5 string concatination.

I will update the PR. I am surprised that the Travis pipeline does not fail because of this if it indeed is an enforced guideline.

codeclown and others added some commits Jul 23, 2018

@pygy

This comment has been minimized.

Copy link
Member

pygy commented Aug 6, 2018

Thanks for the PR @codeclown!

@pygy pygy requested a review from tivac as a code owner Aug 6, 2018

@pygy pygy merged commit fd7cf80 into MithrilJS:next Aug 6, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

porsager added a commit to porsager/mithril.js that referenced this pull request Aug 6, 2018

isiahmeadows added a commit that referenced this pull request Nov 14, 2018

output mithril, stream and ospec esm versions on build - fixes #2112 (#…
…2194)

* output mithril, stream and ospec esm versions on build

* Add esm bundles

* [request] Clearer error message for JSON deserialization failure (#2195)

* Bundled output for commit fd7cf80 [skip ci]

* Fix #1714 conditionally halting stream (#2200)

* Fix #1714 conditionally halting stream

* Add note in changelog

* Do not include stream as named export in mithril.esm.js

* Rename mithril.min.esm.js to mithril.esm.min.js

* Add esm files to eslintignore

* Add named exports

* Add hyperscript `m` as named export

* Add builds with export changes

* checkout regular bundled files

* Change .esm.js to .mjs

* Update pkg module to point to .mjs

* Fix for export names to avoid collision

* Updated bundled files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment