Permalink
Browse files

Added error handing and messages for write failures.

  • Loading branch information...
kriszyp committed Nov 1, 2010
1 parent 9b21d84 commit eb3e515b661743773a7eeda919712166ba3cdf70
Showing with 8 additions and 3 deletions.
  1. +8 −3 lib/jsgi-node.js
View
@@ -138,6 +138,7 @@ function Response( response, stream ) {
data.then(
handle,
function( error ) {
+ sys.puts("Error: " + error.stack);
handle({ status:500, headers:{}, body:[error.message] });
},
function( data ){
@@ -165,7 +166,7 @@ function Response( response, stream ) {
try{
response.write( chunk, data.body.encoding || "utf8" );
}catch(e){
- response.write( "error writing " + chunk + e, data.body.encoding || "utf8" );
+ sys.puts( "error writing " + chunk + e);
}
});
@@ -195,8 +196,12 @@ function Response( response, stream ) {
// if it is not too late, set the status
response.writeHead(500, {});
}catch(e2){}
- response.write( "Error: " + e.stack );
- response.end();
+ try{
+ response.write( "Error: " + e.stack );
+ response.end();
+ }catch(e3){
+ sys.puts(e3.stack);
+ }
}
}
}

0 comments on commit eb3e515

Please sign in to comment.