You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 25, 2018. It is now read-only.
Under the Node.js v7.5.0 Documentation Errors page, it is mentioned -
A handful of typically asynchronous methods in the Node.js API may still use the throw mechanism to raise exceptions that must be handled using try / catch. There is no comprehensive list of such methods; please refer to the documentation of each method to determine the appropriate error handling mechanism required.
To be honest, I wasn't aware of the following and assumed errors were passed as described just above it via err parameter to the callback function. Would you mind adding such function or its use case via try/catch block since it might create some confusion over its usage.
The rule of thumb is this: validation errors (bad inputs) throw exceptions, runtime errors are events.
Say you pass null to a function that expects a string, that's a validation error. Trying to look up the IP address of a non-existing domain name? A runtime error.
In general, when an otherwise asynchronous function throws an exception, it means you need to fix your application because it calls node functions the wrong way.
I'm reasonably sure the documentation mentions the above in a few places but perhaps a more centralized overview is called for.
Under the Node.js v7.5.0 Documentation Errors page, it is mentioned -
To be honest, I wasn't aware of the following and assumed errors were passed as described just above it via
err
parameter to the callback function. Would you mind adding such function or its use case via try/catch block since it might create some confusion over its usage.Reference - StackOverflow.
The text was updated successfully, but these errors were encountered: