aboutsummaryrefslogtreecommitdiff
path: root/node_modules/node-fetch/ERROR-HANDLING.md
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-05-03 15:35:00 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-05-03 15:35:00 +0200
commitde98e0b232509d5f40c135d540a70e415272ff85 (patch)
treea79222a5b58484ab3b80d18efcaaa7ccc4769b33 /node_modules/node-fetch/ERROR-HANDLING.md
parente0c9d480a73fa629c1e4a47d3e721f1d2d345406 (diff)
node_modules
Diffstat (limited to 'node_modules/node-fetch/ERROR-HANDLING.md')
-rw-r--r--node_modules/node-fetch/ERROR-HANDLING.md21
1 files changed, 21 insertions, 0 deletions
diff --git a/node_modules/node-fetch/ERROR-HANDLING.md b/node_modules/node-fetch/ERROR-HANDLING.md
new file mode 100644
index 000000000..0e4025d14
--- /dev/null
+++ b/node_modules/node-fetch/ERROR-HANDLING.md
@@ -0,0 +1,21 @@
+
+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](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.
+
+- All errors comes with `err.message` detailing the cause of errors.
+
+- All errors originated from `node-fetch` are marked with custom `err.type`.
+
+- 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.
+
+- [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.
+
+List of error types:
+
+- 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