gracenode
Advanced tools
Comparing version 0.2.24 to 0.2.25
@@ -70,2 +70,10 @@ var gracenode = require('../../../'); | ||
// override _errorHandler for responseObj.error() | ||
responseObj._errorHandler = function (error, status) { | ||
if (typeof error === 'string') { | ||
error = new Error(error); | ||
} | ||
errorHandler(server, req, res, parsedUrl, requestObj, error.message, status, startTime); | ||
}; | ||
// set up exception handler. default is true | ||
@@ -83,3 +91,3 @@ if (config.respondOnException || config.respondOnException === undefined) { | ||
log.verbose(parsedUrl.controller + '.' + parsedUrl.method + ' [' + requestObj.getMethod() + '] executed'); | ||
log.verbose(parsedUrl.controller + '/' + parsedUrl.method + ' [' + requestObj.getMethod() + '] executed'); | ||
@@ -187,3 +195,3 @@ // invoke the controller method | ||
var responder = new response.create(server, req, res, startTime); | ||
responder.error(JSON.stringify(msg), status); | ||
responder._error(JSON.stringify(msg), status); | ||
} |
@@ -47,4 +47,5 @@ var gracenode = require('../../'); | ||
log.verbose('response content type: JSON'); | ||
setupFinish(this._request, this._response, this._server, this._startTime); | ||
respondJSON(this._request, this._response, content, status); | ||
setupFinish(this._request, this._response, this._server, this._startTime); | ||
finish(this._request, this._response, this._server); | ||
}; | ||
@@ -54,4 +55,5 @@ | ||
log.verbose('response content type: DATA'); | ||
setupFinish(this._request, this._response, this._server, this._startTime); | ||
respondHTML(this._request, this._response, content, status); | ||
setupFinish(this._request, this._response, this._server, this._startTime); | ||
finish(this._request, this._response, this._server); | ||
}; | ||
@@ -61,4 +63,5 @@ | ||
log.verbose('response content type: DATA'); | ||
setupFinish(this._request, this._response, this._server, this._startTime); | ||
respondData(this._request, this._response, content, status); | ||
setupFinish(this._request, this._response, this._server, this._startTime); | ||
finish(this._request, this._response, this._server); | ||
}; | ||
@@ -68,11 +71,9 @@ | ||
log.verbose('response content type: File'); | ||
setupFinish(this._request, this._response, this._server, this._startTime); | ||
respondFILE(this._request, this._response, content, status); | ||
setupFinish(this._request, this._response, this._server, this._startTime); | ||
finish(this._request, this._response, this._server); | ||
}; | ||
Response.prototype.error = function (content, status) { | ||
log.verbose('response content type: Error'); | ||
log.error('(url:' + this._request.url + ')', content); | ||
respondERROR(this._request, this._response, content, status); | ||
setupFinish(this._request, this._response, this._server, this._startTime); | ||
this._errorHandler(content, status); | ||
}; | ||
@@ -82,4 +83,18 @@ | ||
log.verbose('response content type: Redirect'); | ||
setupFinish(this._request, this._response, this._server, this._startTime); | ||
respondRedirect(this._request, this._response, content, status); | ||
finish(this._request, this._response, this._server); | ||
}; | ||
// overrriden by controller | ||
Response.prototype._errorHandler = function () { | ||
}; | ||
Response.prototype._error = function (content, status) { | ||
log.verbose('response content type: Error'); | ||
log.error('(url:' + this._request.url + ')', content); | ||
setupFinish(this._request, this._response, this._server, this._startTime); | ||
respondERROR(this._request, this._response, content, status); | ||
finish(this._request, this._response, this._server); | ||
}; | ||
@@ -95,2 +110,5 @@ | ||
}); | ||
} | ||
function finish(req, res, server) { | ||
res.emit('end', req.url); | ||
@@ -97,0 +115,0 @@ // this will be called when the server finishes all operation (not when the response data sent) |
{ | ||
"name": "gracenode", | ||
"description": "framework for nodejs application", | ||
"version": "0.2.24", | ||
"version": "0.2.25", | ||
"author": "Nobuyori Takahashi <voltrue2@yahoo.com>", | ||
@@ -6,0 +6,0 @@ "repository": { |
1187386
9584