Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix error handling

Change-Id: If5437fc39b17deccf8c3466e45ed1103da08a636
  • Loading branch information...
commit 2f56d1e996b4c210c93bcee89055d971e1b95e4c 1 parent 860d9e8
Tim Caswell authored December 25, 2010

Showing 2 changed files with 6 additions and 4 deletions. Show diff stats Hide diff stats

  1. 2  package.json
  2. 8  stack.js
2  package.json
@@ -2,7 +2,7 @@
2 2
   "name": "stack",
3 3
   "description": "Stack is a minimal http module system for node.js",
4 4
   "tags": ["connect", "middleware", "stack", "http"],
5  
-  "version": "0.0.2",
  5
+  "version": "0.0.3",
6 6
   "author": "Tim Caswell <tim@creationix.com>",
7 7
   "repository": {
8 8
     "type": "git",
8  stack.js
... ...
@@ -1,15 +1,16 @@
1 1
 function Stack(/*layers*/) {
2  
-  var handle = Stack.error;
  2
+  var error = Stack.errorHandler,
  3
+      handle = error;
3 4
   Array.prototype.slice.call(arguments).reverse().forEach(function (layer) {
4 5
     var child = handle;
5 6
     handle = function (req, res) {
6 7
       try {
7 8
         layer(req, res, function (err) {
8  
-          if (err) { return Stack.error(req, res, err); }
  9
+          if (err) { return error(req, res, err); }
9 10
           child(req, res);
10 11
         });
11 12
       } catch (err) {
12  
-        Stack.error(req, res, err);
  13
+        error(req, res, err);
13 14
       }
14 15
     };
15 16
   });
@@ -17,6 +18,7 @@ function Stack(/*layers*/) {
17 18
 }
18 19
 Stack.errorHandler = function error(req, res, err) {
19 20
   if (err) {
  21
+    console.error(err.stack + "\n");
20 22
     res.writeHead(500, {"Content-Type": "text/plain"});
21 23
     res.end(err.stack + "\n");
22 24
     return;

0 notes on commit 2f56d1e

Please sign in to comment.
Something went wrong with that request. Please try again.