feat(CordovaError): support for error cause & more#121
Merged
Conversation
48fee1d to
b85e6d3
Compare
Codecov Report
@@ Coverage Diff @@
## master #121 +/- ##
==========================================
+ Coverage 88.02% 88.04% +0.02%
==========================================
Files 20 20
Lines 1169 1171 +2
==========================================
+ Hits 1029 1031 +2
Misses 140 140
Continue to review full report at Codecov.
|
erisu
approved these changes
Dec 13, 2019
b85e6d3 to
a6101a4
Compare
erisu
approved these changes
Jan 9, 2020
a6101a4 to
3f8c8ee
Compare
Contributor
Author
|
FYI: My plan is to merge this after the big refactor PRs have all landed |
3f8c8ee to
0920aaf
Compare
This commit bases CordovaError on the popular [joyent/node-verror].
We actually use @netflix/nerror, a VError fork, for now. That's because
we do not want printf style error formatting support and that fork
allows to disable it. There's [ongoing work][1] to integrate that change
into the original VError.
So basically CordovaError behaves like PError but with all the static
methods from VError and different parameter ordering for its
constructor.
One change that could break some existing tests in repositories that use
cordova-common is that `toString` (for errors without a cause argument)
now behaves like the Error default again:
new CordovaError('foo').toString();
// old result: 'foo'
// new result: 'CordovaError: foo'
[joyent/node-verror]: https://github.com/joyent/node-verror
[1]: TritonDataCenter/node-verror#63 (comment)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
This allows us to properly wrap caught errors in a
CordovaError:Assume we catch above
CordovaErroraserr2, then we can obtain some nicely formatted information from it:This is a follow-up to #117. Should preferably be merged after #120.
Description
This commit bases CordovaError on the popular joyent/node-verror.
We actually use @netflix/nerror, a VError fork for now. That's because
we do not want printf style error formatting support and that fork
allows to disable it. There's ongoing work to integrate that change
into the original VError.
So basically CordovaError behaves like PError but with all the static
methods from VError and different parameter ordering for its
constructor.
One change that could break some existing tests in repositories that use
cordova-common is that
toString(for errors without a cause argument)now behaves like the Error default again:
Here's an overview of available similar packages.
Testing
Added tests that exercised the parts of the VError API that we will be using.