Comparing version 0.2.1 to 0.2.3
@@ -210,3 +210,3 @@ "use strict"; | ||
parseValue: function BodyParser_parseValue(str) { | ||
return str.replace(/(.*)(([\S\s]+)(Content-Type:(.*)))?/i, '').slice(4); | ||
return str.replace(/([\s\S]+name="[^\n]+)([\s\S]+Content-Type[^\n]+)?/i, '').slice(3); | ||
} | ||
@@ -213,0 +213,0 @@ }); |
@@ -79,2 +79,3 @@ "use strict"; | ||
this.isCompressionEnabled = false; | ||
this.id = null; | ||
// body and isForwarded can be overriden | ||
@@ -90,3 +91,6 @@ core.extend(this, config); | ||
this.isCompressed = false; | ||
this.id = this._uuid(); | ||
if (!this.id) { | ||
this.id = this._uuid(); | ||
} | ||
}, | ||
@@ -357,3 +361,3 @@ /** | ||
forwardUrl: function Request_forwardUrl(url) { | ||
var request; | ||
var request, that = this; | ||
if (this.url === url) { | ||
@@ -369,2 +373,3 @@ throw new error.HttpError(500, { | ||
isForwarded: true, | ||
id: this.id, | ||
body: this.body | ||
@@ -377,2 +382,7 @@ }, url); | ||
// destroy current request on end of request | ||
request.onEnd(function () { | ||
that._destroy(); | ||
}); | ||
return request.parse(); | ||
@@ -391,3 +401,3 @@ } | ||
var request; | ||
var request, that = this; | ||
@@ -407,2 +417,3 @@ if (router.trim(this.route, "/") === router.trim(route, '/')) { | ||
isForwarded: true, | ||
id: this.id, | ||
body: this.body | ||
@@ -415,2 +426,6 @@ }, router.createUrl(route, params)); | ||
}); | ||
// destroy current request on end of request | ||
request.onEnd(function () { | ||
that._destroy(); | ||
}); | ||
@@ -614,3 +629,3 @@ return request.parse(); | ||
_handleError: function Request_handleError(response) { | ||
var request, code; | ||
var request, code, that = this; | ||
@@ -652,6 +667,5 @@ if (this.isRendered) { | ||
body: this.body, | ||
isERROR: true | ||
isERROR: true, | ||
id: this.id | ||
}, router.createUrl(router.getErrorRoute())); | ||
// destroy current request this must after we transfer reference of request/response/body to forwarded route | ||
this._destroy(); | ||
// pass exception response over parsed url query as query parameter | ||
@@ -664,4 +678,7 @@ // assign to exception | ||
// destroy current request on end of error request | ||
request.onEnd(function () { | ||
that._destroy(); | ||
}); | ||
return request.parse(); | ||
@@ -771,4 +788,2 @@ } else { | ||
var errors = ['HttpError', 'DataError', 'Exception']; | ||
if (!promise) { | ||
@@ -779,7 +794,3 @@ return new Promise(function (resolve, reject) { | ||
} catch (e) { | ||
if (e && errors.indexOf(e.name) > -1) { | ||
reject(e); | ||
} else { | ||
reject(new error.HttpError(500, {}, "Error on executing action", e)); | ||
} | ||
reject(new error.HttpError(500, {}, "Error on executing action", e)); | ||
} | ||
@@ -800,7 +811,3 @@ }); | ||
} catch (e) { | ||
if (e && errors.indexOf(e.name) > -1) { | ||
throw e; | ||
} else { | ||
throw new error.HttpError(500, {}, "Error on executing action", e); | ||
} | ||
throw new error.HttpError(500, {}, "Error on executing action", e); | ||
} | ||
@@ -807,0 +814,0 @@ } |
@@ -49,12 +49,18 @@ "use strict"; | ||
_construct: function Exception(message, e) { | ||
var stack; | ||
if (e && e.message) { | ||
message = message + ', ' + e.message; | ||
} | ||
if (!(e instanceof Error)) { | ||
if (Type.isObject(e)) { | ||
if (e && e.message) { | ||
message = message + ', ' + e.message; | ||
} | ||
stack = e.stack; | ||
e = null; | ||
} else if (Type.isString(e)) { | ||
stack = e; | ||
} else { | ||
e = new Error(); | ||
stack = e.stack; | ||
} | ||
throw toString('Exception', core.trace(8, 9), message, e.stack); | ||
throw toString('Exception', core.trace(8, 9), message, stack); | ||
} | ||
@@ -78,11 +84,19 @@ } | ||
if (e && e.message) { | ||
message = message + ', ' + e.message; | ||
} | ||
var stack; | ||
if (!(e instanceof Error)) { | ||
if (Type.isObject(e)) { | ||
if (e && e.message) { | ||
message = message + ', ' + e.message; | ||
} | ||
stack = e.stack; | ||
e = null; | ||
} else if (Type.isString(e)) { | ||
stack = e; | ||
} else { | ||
e = new Error(); | ||
stack = e.stack; | ||
} | ||
throw toString('DataError', core.trace(8, 9), message, e.stack, core.inspect(data)); | ||
throw toString('DataError', core.trace(8, 9), message, stack, core.inspect(data)); | ||
} | ||
@@ -104,12 +118,18 @@ } | ||
_construct: function HttpError(code, data, message, e) { | ||
var stack; | ||
if (e && e.message) { | ||
message = message + ', ' + e.message; | ||
} | ||
if (!(e instanceof Error)) { | ||
if (Type.isObject(e)) { | ||
if (e && e.message) { | ||
message = message + ', ' + e.message; | ||
} | ||
stack = e.stack; | ||
e = null; | ||
} else if (Type.isString(e)) { | ||
stack = e; | ||
} else { | ||
e = new Error(); | ||
stack = e.stack; | ||
} | ||
throw toString('HttpError', core.trace(8, 9), message, e.stack, core.inspect(data), code); | ||
throw toString('HttpError', core.trace(8, 9), message, stack, core.inspect(data), code); | ||
} | ||
@@ -131,11 +151,18 @@ } | ||
function silentHttpError(code, data, message, e) { | ||
if (e && e.message) { | ||
message = message + ', ' + e.message; | ||
} | ||
var stack; | ||
if (!(e instanceof Error)) { | ||
if (Type.isObject(e)) { | ||
if (e && e.message) { | ||
message = message + ', ' + e.message; | ||
} | ||
stack = e.stack; | ||
e = null; | ||
} else if (Type.isString(e)) { | ||
stack = e; | ||
} else { | ||
e = new Error(); | ||
stack = e.stack; | ||
} | ||
return toString('SlientHttpError', core.trace(8, 9), message, e.stack, core.inspect(data), code); | ||
return toString('SlientHttpError', core.trace(8, 9), message, stack, core.inspect(data), code); | ||
} | ||
@@ -142,0 +169,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"description": "Powerful lightweight mvc framework for nodejs", | ||
"version": "0.2.1", | ||
"version": "0.2.3", | ||
"dependencies": { | ||
@@ -8,0 +8,0 @@ "mongoose": "4.0.x", |
MVC JS [![Build Status](https://api.travis-ci.org/AdminJuwel191/node-mvc.svg?branch=master)](https://travis-ci.org/AdminJuwel191/node-mvc) 0.2.0 | ||
MVC JS [![Build Status](https://api.travis-ci.org/AdminJuwel191/node-mvc.svg?branch=0.2.x)](https://travis-ci.org/AdminJuwel191/node-mvc) 0.2.3 | ||
===== | ||
@@ -4,0 +4,0 @@ |
Sorry, the diff of this file is not supported yet
158068
5099