nats-hemera
Advanced tools
Comparing version 5.0.0-rc.5 to 5.0.0-rc.6
@@ -845,9 +845,17 @@ /** | ||
const result = action(self._request.payload.pattern, (err, result) => | ||
const result = action(self._request.payload.pattern, (err, result) => { | ||
if (err) { | ||
self._isValidError(err) | ||
} | ||
self.reply.send(err || result) | ||
) | ||
}) | ||
const isPromise = result && typeof result.then === 'function' | ||
if (isPromise) { | ||
result.then(x => self.reply.send(x)).catch(e => self.reply.send(e)) | ||
result.then(x => self.reply.send(x)).catch(err => { | ||
if (err) { | ||
self._isValidError(err) | ||
} | ||
self.reply.send(err) | ||
}) | ||
} | ||
@@ -858,2 +866,16 @@ }) | ||
/** | ||
* | ||
* @param {*} err | ||
*/ | ||
_isValidError(err) { | ||
if (!(err instanceof Error)) { | ||
this.log.error( | ||
new Errors.HemeraError( | ||
`Response error must be derivated from type 'Error' but got '${typeof err}'` | ||
) | ||
) | ||
} | ||
} | ||
/** | ||
* Unsubscribe a topic or subscription id from NATS and Hemera | ||
@@ -860,0 +882,0 @@ * |
{ | ||
"name": "nats-hemera", | ||
"author": "Dustin Deus (https://github.com/StarpTech)", | ||
"version": "5.0.0-rc.5", | ||
"version": "5.0.0-rc.6", | ||
"main": "lib/index.js", | ||
@@ -6,0 +6,0 @@ "homepage": "https://hemerajs.github.io/hemera/", |
Sorry, the diff of this file is not supported yet
66656
2692