nats-hemera
Advanced tools
Comparing version 0.3.11 to 0.3.12
@@ -23,3 +23,13 @@ 'use strict'; | ||
return stringify(msg); | ||
try { | ||
return { | ||
value: stringify(msg) | ||
}; | ||
} catch (error) { | ||
return { | ||
error | ||
}; | ||
} | ||
} | ||
@@ -26,0 +36,0 @@ }]); |
@@ -66,4 +66,12 @@ 'use strict'; | ||
ctx._request = ctx._encoder.encode.call(ctx, ctx._message); | ||
var m = ctx._encoder.encode.call(ctx, ctx._message); | ||
// throw encoding issue | ||
if (m.error) { | ||
return next(m.error); | ||
} | ||
ctx._request = m.value; | ||
ctx.log.info(pattern, `ACT_OUTBOUND - ID:${String(ctx._message.request.id)}`); | ||
@@ -98,5 +106,13 @@ | ||
var msg = this._request.value; | ||
var ctx = this; | ||
var m = ctx._decoder.decode.call(ctx, ctx._request); | ||
if (m.error) { | ||
return next(m.error); | ||
} | ||
var msg = m.value; | ||
if (msg) { | ||
@@ -110,2 +126,4 @@ | ||
ctx._request = m; | ||
ctx.emit('onServerPreRequest', ctx); | ||
@@ -112,0 +130,0 @@ |
@@ -405,3 +405,12 @@ 'use strict'; | ||
this._message = message; | ||
var m = this._encoder.encode.call(this, message); | ||
// attach encoding issues | ||
if (m.error) { | ||
message.error = _errio2.default.toObject(m.error); | ||
message.result = null; | ||
} | ||
this._message = m.value; | ||
} | ||
@@ -446,6 +455,4 @@ /** | ||
var msg = self._encoder.encode.call(self, self._message); | ||
// send error back to callee | ||
return self.send(self._replyTo, msg, function () { | ||
return self.send(self._replyTo, self._message, function () { | ||
@@ -466,5 +473,3 @@ // let it crash | ||
var _msg = self._encoder.encode.call(self, self._message); | ||
return this.send(this._replyTo, _msg); | ||
return this.send(this._replyTo, self._message); | ||
} | ||
@@ -500,3 +505,3 @@ }); | ||
ctx._replyTo = replyTo; | ||
ctx._request = self._decoder.decode.call(ctx, request); | ||
ctx._request = request; | ||
ctx._pattern = {}; | ||
@@ -520,12 +525,2 @@ ctx._actMeta = {}; | ||
// invalid payload | ||
if (self._request.error) { | ||
var _error = new _errors2.default.ParseError(_constants2.default.PAYLOAD_PARSING_ERROR, { | ||
topic | ||
}).causedBy(self._request.error); | ||
return self.finish(replyTo, _error); | ||
} | ||
var requestType = self._request.value.request.type; | ||
@@ -648,8 +643,8 @@ self._pattern = self._request.value.pattern; | ||
var _error2 = new _errors2.default.HemeraError(_constants2.default.MISSING_IMPLEMENTATION, { | ||
var _error = new _errors2.default.HemeraError(_constants2.default.MISSING_IMPLEMENTATION, { | ||
pattern | ||
}); | ||
this.log.error(_error2); | ||
throw _error2; | ||
this.log.error(_error); | ||
throw _error; | ||
} | ||
@@ -686,8 +681,8 @@ | ||
var _error3 = new _errors2.default.HemeraError(_constants2.default.PATTERN_ALREADY_IN_USE, { | ||
var _error2 = new _errors2.default.HemeraError(_constants2.default.PATTERN_ALREADY_IN_USE, { | ||
pattern | ||
}); | ||
this.log.error(_error3); | ||
throw _error3; | ||
this.log.error(_error2); | ||
throw _error2; | ||
} | ||
@@ -742,8 +737,8 @@ | ||
var _error4 = new _errors2.default.HemeraError(_constants2.default.EXTENSION_ERROR).causedBy(err); | ||
var _error3 = new _errors2.default.HemeraError(_constants2.default.EXTENSION_ERROR).causedBy(err); | ||
self.log.error(_error4); | ||
self.log.error(_error3); | ||
if (hasCallback) { | ||
return cb.call(self, _error4); | ||
return cb.call(self, _error3); | ||
} | ||
@@ -774,10 +769,10 @@ | ||
var _error5 = new _errors2.default.ParseError(_constants2.default.PAYLOAD_PARSING_ERROR, { | ||
var _error4 = new _errors2.default.ParseError(_constants2.default.PAYLOAD_PARSING_ERROR, { | ||
pattern: self._cleanPattern | ||
}).causedBy(self._response.error); | ||
self.log.error(_error5); | ||
self.log.error(_error4); | ||
if (hasCallback) { | ||
return cb.call(self, _error5); | ||
return cb.call(self, _error4); | ||
} | ||
@@ -790,8 +785,8 @@ } | ||
var _error6 = new _errors2.default.HemeraError(_constants2.default.EXTENSION_ERROR).causedBy(err); | ||
var _error5 = new _errors2.default.HemeraError(_constants2.default.EXTENSION_ERROR).causedBy(err); | ||
self.log.error(_error6); | ||
self.log.error(_error5); | ||
if (hasCallback) { | ||
return cb.call(self, _error6); | ||
return cb.call(self, _error5); | ||
} | ||
@@ -808,7 +803,7 @@ | ||
var responseErrorCause = responseError.cause; | ||
var _error7 = new _errors2.default.BusinessError(_constants2.default.BUSINESS_ERROR, { | ||
var _error6 = new _errors2.default.BusinessError(_constants2.default.BUSINESS_ERROR, { | ||
pattern: self._cleanPattern | ||
}).causedBy(responseErrorCause ? responseError.cause : responseError); | ||
self.log.error(_error7); | ||
self.log.error(_error6); | ||
@@ -823,7 +818,7 @@ return cb.call(self, responseError); | ||
var _error8 = new _errors2.default.FatalError(_constants2.default.FATAL_ERROR, { | ||
var _error7 = new _errors2.default.FatalError(_constants2.default.FATAL_ERROR, { | ||
pattern: self._cleanPattern | ||
}).causedBy(err); | ||
self.log.fatal(_error8); | ||
self.log.fatal(_error7); | ||
@@ -875,7 +870,7 @@ // let it crash | ||
var _error9 = new _errors2.default.FatalError(_constants2.default.FATAL_ERROR, { | ||
var _error8 = new _errors2.default.FatalError(_constants2.default.FATAL_ERROR, { | ||
pattern | ||
}).causedBy(err); | ||
_this4.log.fatal(_error9); | ||
_this4.log.fatal(_error8); | ||
@@ -882,0 +877,0 @@ // let it crash |
@@ -14,3 +14,13 @@ // @flow | ||
return stringify(msg) | ||
try { | ||
return { | ||
value: stringify(msg) | ||
} | ||
} catch (error) { | ||
return { | ||
error | ||
} | ||
} | ||
} | ||
@@ -56,3 +66,3 @@ } | ||
val.count++ | ||
return | ||
return | ||
} else if (parent) { | ||
@@ -59,0 +69,0 @@ |
@@ -10,3 +10,3 @@ // @flow | ||
import Util from './util' | ||
import Hoek from'hoek' | ||
import Hoek from 'hoek' | ||
@@ -60,4 +60,12 @@ module.exports.onClientPreRequest = [function onClientPreRequest(next: Function) { | ||
ctx._request = ctx._encoder.encode.call(ctx, ctx._message) | ||
let m = ctx._encoder.encode.call(ctx, ctx._message) | ||
// throw encoding issue | ||
if (m.error) { | ||
return next(m.error) | ||
} | ||
ctx._request = m.value | ||
ctx.log.info(pattern, `ACT_OUTBOUND - ID:${String(ctx._message.request.id)}`) | ||
@@ -92,5 +100,13 @@ | ||
let msg = this._request.value | ||
let ctx: Hemera = this | ||
let m = ctx._decoder.decode.call(ctx, ctx._request) | ||
if(m.error) { | ||
return next(m.error) | ||
} | ||
let msg = m.value | ||
if (msg) { | ||
@@ -104,2 +120,4 @@ | ||
ctx._request = m | ||
ctx.emit('onServerPreRequest', ctx) | ||
@@ -106,0 +124,0 @@ |
@@ -409,4 +409,13 @@ // @flow | ||
this._message = message | ||
let m = this._encoder.encode.call(this, message) | ||
// attach encoding issues | ||
if (m.error) { | ||
message.error = Errio.toObject(m.error) | ||
message.result = null | ||
} | ||
this._message = m.value | ||
} | ||
@@ -448,6 +457,4 @@ /** | ||
const msg = self._encoder.encode.call(self, self._message) | ||
// send error back to callee | ||
return self.send(self._replyTo, msg, () => { | ||
return self.send(self._replyTo, self._message, () => { | ||
@@ -470,5 +477,3 @@ // let it crash | ||
const msg = self._encoder.encode.call(self, self._message) | ||
return this.send(this._replyTo, msg) | ||
return this.send(this._replyTo, self._message) | ||
} | ||
@@ -502,3 +507,3 @@ | ||
ctx._replyTo = replyTo | ||
ctx._request = self._decoder.decode.call(ctx, request) | ||
ctx._request = request | ||
ctx._pattern = {} | ||
@@ -522,12 +527,2 @@ ctx._actMeta = {} | ||
// invalid payload | ||
if (self._request.error) { | ||
let error = new Errors.ParseError(Constants.PAYLOAD_PARSING_ERROR, { | ||
topic | ||
}).causedBy(self._request.error) | ||
return self.finish(replyTo, error) | ||
} | ||
let requestType = self._request.value.request.type | ||
@@ -534,0 +529,0 @@ self._pattern = self._request.value.pattern |
{ | ||
"name": "nats-hemera", | ||
"author": "Dustin Deus (https://github.com/StarpTech)", | ||
"version": "0.3.11", | ||
"version": "0.3.12", | ||
"main": "build/index.js", | ||
@@ -6,0 +6,0 @@ "homepage": "https://hemerajs.github.io/hemera/", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
140848
39
2590