Skip to content

Conversation

@coolaj86
Copy link
Contributor

@coolaj86 coolaj86 commented Nov 3, 2021

ExpressJS has built-in error handling.

This uses that (via .catch(next)), rather that duplicating error handling logic throughout.

Also

  • this removes the redundant use of try/catch (since async/await is already being used, which lends itself to using .catch for clean, easy-to-read async error handling)
  • removes redundant returns that may be confusing to the reader (nothing is actually returned)
  • adds 'use strict'; (unlike front-end code which is transpiled, node code must explicitly set 'use strict';, otherwise errors may not be caught properly)
  • ran npx prettier@2.x -w index.js with existing .prettierrc, which caused some whitespace changes
    • (though this looks off, so perhaps some expected rules are missing from the .prettierrc?)

Preview

Best viewed with whitespace changes ignored:
https://github.com/plaid/quickstart/pull/285/files?diff=unified&w=1

@coolaj86 coolaj86 force-pushed the idiomatic-express-js branch 2 times, most recently from a8aa99d to 8e2b0b4 Compare November 3, 2021 21:56
@coolaj86 coolaj86 force-pushed the idiomatic-express-js branch from 8e2b0b4 to 219b126 Compare November 3, 2021 21:58
@coolaj86 coolaj86 changed the title feature: use built-in express error handling refactor: idiomatic express w/ built-in express error and async handling Nov 3, 2021
@lindawoo-plaid lindawoo-plaid merged commit 828f8c8 into plaid:master Dec 9, 2021
@lindawoo-plaid
Copy link
Contributor

thank you @coolaj86

SpencerHHurst pushed a commit to SpencerHHurst/quickstart that referenced this pull request Jul 10, 2024
…ing (plaid#285)

* feature: use built-in express error handling

* refactor: remove redundant resolve indirection

Co-authored-by: lindawoo-plaid <77688518+lindawoo-plaid@users.noreply.github.com>
fisherrjd pushed a commit to fisherrjd/quickstart that referenced this pull request Oct 12, 2024
…ing (plaid#285)

* feature: use built-in express error handling

* refactor: remove redundant resolve indirection

Co-authored-by: lindawoo-plaid <77688518+lindawoo-plaid@users.noreply.github.com>
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.

2 participants