Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

ERROR-HANDLING.md 1.2 KiB

3 anos atrás
123456789101112131415161718192021
  1. Error handling with node-fetch
  2. ==============================
  3. Because `window.fetch` isn't designed to transparent about the cause of request errors, we have to come up with our own solutions.
  4. The basics:
  5. - All [operational errors](https://www.joyent.com/node-js/production/design/errors) are rejected as [FetchError](https://github.com/bitinn/node-fetch/blob/master/lib/fetch-error.js), you can handle them all through promise `catch` clause.
  6. - All errors comes with `err.message` detailing the cause of errors.
  7. - All errors originated from `node-fetch` are marked with custom `err.type`.
  8. - All errors originated from Node.js core are marked with `err.type = system`, and contains addition `err.code` and `err.errno` for error handling, they are alias to error codes thrown by Node.js core.
  9. - [Programmer errors](https://www.joyent.com/node-js/production/design/errors) are either thrown as soon as possible, or rejected with default `Error` with `err.message` for ease of troubleshooting.
  10. List of error types:
  11. - Because we maintain 100% coverage, see [test.js](https://github.com/bitinn/node-fetch/blob/master/test/test.js) for a full list of custom `FetchError` types, as well as some of the common errors from Node.js