Permalink
Browse files

dealing with errors documentation

  • Loading branch information...
fgalassi authored and tj committed Dec 30, 2012
1 parent f0add6c commit e097cb7c97b1b80f7eeaf95e66c01fb6dee0a5f7
Showing with 16 additions and 1 deletion.
  1. +16 −1 docs/index.md
View
@@ -96,6 +96,21 @@
});
+## Dealing with errors
+
+ On a network error (e.g. connection refused or timeout), SuperAgent emits
+ `error` unless you pass `.end()` a callback with two parameters. Then
+ SuperAgent will invoke it with the error first, followed by a null response.
+
+ request
+ .get('http://wrongurl')
+ .end(function(err, res){
+ console.log('ERROR: ', err)
+ });
+
+ On HTTP errors instead, SuperAgent populates the response with flags
+ indicating the error. See `Response status` below.
+
## Setting header fields
Setting header fields is simple, invoke `.set()` with a field name and value:
@@ -201,4 +216,4 @@
res.badRequest = 400 == status;
res.unauthorized = 401 == status;
res.notAcceptable = 406 == status;
- res.notFound = 404 == status;
+ res.notFound = 404 == status;

0 comments on commit e097cb7

Please sign in to comment.