This repository has been archived by the owner on Mar 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Allow errors bubble up to the caller (#83)
* fix: Allow errors bubble up to the caller This patch prevents unhandled Promise rejections from crashing the process by allowing the caller to handle them instead. To properly call `Builder#analyze()`, you **SHOULD** change your code from: ```js builder.analyze(function(results) { // Do something with results }); ``` To: ```js builder.analyze(function(err, results) { if (err) { // handle error } // Do something with results }); ``` However, if you do not update your code, `axe-webdriverjs` will continue to function the same way (for the time being), but will print a deprecation warning to `stderr`.⚠️ This functionality will be removed in the next major release.⚠️ Additionally, when using the Promise returned by `Builder#analyze()`, you **SHOULD** add a `.catch()` block to handle the possible rejection. For example: ```js builder .analyze() .then(results => { // Do something with results }) .catch(err => { // handle error }); ``` If neither a `.catch()` block or a callback are provided, an unhandled rejection will occur and the Node process will crash. ☠️ NOTE: when using a Promise _and_ a callback, the Promise will never be rejected. Either the callback will be provided the error, or the error will be thrown instead. This ensures we don't require users to handle the same error twice. New tests have been added ensuring this behavior works as expected. Additionally, all old tests have been migrated to the new API, which should help encourage users to do the same. Fixes #56. * chore: update deprecation message
- Loading branch information
1 parent
52a2284
commit 5b1cf4e
Showing
10 changed files
with
221 additions
and
32 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.