Permalink
Browse files

Merged

  • Loading branch information...
2 parents dc2ba6c + 42dfd2a commit 44514531b662b3b3b7653c7b0cdde0f1f7d7b55c @MiguelMadero committed Oct 3, 2012
Showing with 42 additions and 27 deletions.
  1. +1 −1 bin/cli.js
  2. +1 −1 lib/base_controller.js
  3. +9 −3 lib/cluster/master.js
  4. +30 −21 lib/response/errors.js
  5. +1 −1 templates/Jakefile
View
@@ -142,7 +142,7 @@ if (cmds.length) {
// Get the model properties
if (cmds.slice(2).length > 0) {
- modelCmd = ',' + cmds.slice(2).join(' ');
+ modelCmd = ',' + cmds.slice(2).join('%');
} else modelCmd = '';
// Add Jake argument based on commands
@@ -511,7 +511,7 @@ controller.BaseController.prototype = new (function () {
@param {Object} err The error to use as the basis for the response.
*/
this.completed = true;
- geddy.errors.respond(this.response, err);
+ geddy.errors.respond(err, this.response);
};
this.transfer = function (action) {
View
@@ -50,6 +50,12 @@ Master.prototype = new (function () {
, loggly
, rotateAndInitByType;
+ // Colon is not valid filepath char in Win
+ // Use percent, that seems to be hunky-dory
+ if (process.platform == 'win32') {
+ now = now.replace(/:/g, '%');
+ }
+
// Set stdout log level
if (this.config.debug) {
levelsByType.stdout = Log.DEBUG;
@@ -79,11 +85,11 @@ Master.prototype = new (function () {
try {
fs.renameSync(currentLog, archivedLog);
}
+ // renameSync doesn't work correctly here for some reason,
+ // fall back to copy/delete
catch (e) {
- // renameSync doesn't seem to work in Windows(of course),
- // so just fucking delete it.
+ file.cpR(currentLog, archivedLog);
fs.unlinkSync(currentLog);
- //file.cpR(currentLog, archivedLog);
}
}
@@ -15,59 +15,68 @@
* limitations under the License.
*
*/
-var response = require('./index');
+var response = require('./index')
+ , errors;
-var errors = new function () {
+errors = new function () {
+
+ var self = this
+ , errorType
+ , errorConstructor
+ , createConstructor;
- var _this = this;
this.errorTypes = {
- 400: 'Bad Request',
- 401: 'Unauthorized',
- 403: 'Forbidden',
- 404: 'Not Found',
- 405: 'Method Not Allowed',
- 406: 'Not Acceptable',
- 500: 'Internal Server Error'
+ 400: 'Bad Request'
+ , 401: 'Unauthorized'
+ , 403: 'Forbidden'
+ , 404: 'Not Found'
+ , 405: 'Method Not Allowed'
+ , 406: 'Not Acceptable'
+ , 500: 'Internal Server Error'
};
- var errorType;
- var errorConstructor;
- var createConstructor = function (code, errorType) {
+ createConstructor = function (code, errorType) {
errorConstructor = function (message) {
this.statusCode = code;
this.statusText = errorType;
this.message = message || errorType;
+
Error.captureStackTrace(this);
}
errorConstructor.prototype = new Error();
+
return errorConstructor;
};
+
for (var code in this.errorTypes) {
// Strip spaces
errorType = this.errorTypes[code].replace(/ /g, '');
+
this[errorType + 'Error'] = createConstructor(code, errorType);
}
// For repetitively redundant name
this.InternalServerError = this.InternalServerErrorError;
- this.respond = function (resp, e) {
+ this.respond = function (err, res) {
// The no-error error ... whoa, meta!
- if (!e) {
+ if (!err) {
throw new Error('No error to respond with.');
}
- var r = new response.Response(resp);
- var code = e.statusCode || 500;
- var msg = '';
+ var r = new response.Response(res)
+ , code = err.statusCode || 500
+ , msg = '';
+
if (geddy.config.detailedErrors) {
- msg = e.stack || e.message || String(e);
+ msg = err.stack || err.message || String(err);
msg = msg.replace(/\n/g, '<br/>');
}
- msg = '<h3>Error: ' + code + ' ' + _this.errorTypes[code] + '</h3>' + msg;
+
+ msg = '<h3>Error: ' + code + ' ' + self.errorTypes[code] + '</h3>' + msg;
r.send(msg, code, {'Content-Type': 'text/html'});
};
}();
-for (var p in errors) { exports[p] = errors[p]; }
+module.exports = errors;
View
@@ -198,7 +198,7 @@ namespace('gen', function () {
return obj;
}
- var itemsArr = properties.split(' ')
+ var itemsArr = properties.split('%')
, name
, type
, args

0 comments on commit 4451453

Please sign in to comment.