ERROR-HANDLING.md
1.2 KB
Error handling with node-fetch
Because window.fetch isn't designed to transparent about the cause of request errors, we have to come up with our own solutions.
The basics:
All operational errors are rejected as FetchError, you can handle them all through promise
catchclause.All errors comes with
err.messagedetailing the cause of errors.All errors originated from
node-fetchare marked with customerr.type.All errors originated from Node.js core are marked with
err.type = system, and contains additionerr.codeanderr.errnofor error handling, they are alias to error codes thrown by Node.js core.Programmer errors are either thrown as soon as possible, or rejected with default
Errorwitherr.messagefor ease of troubleshooting.
List of error types:
- Because we maintain 100% coverage, see test.js for a full list of custom
FetchErrortypes, as well as some of the common errors from Node.js