harcon-amqp
Advanced tools
Comparing version 9.1.1 to 9.1.2
@@ -16,2 +16,21 @@ let _ = require('isa.js') | ||
let errorAttribs = [ 'code', 'message', 'errorCode', 'id', 'reason' ] | ||
function printError (err) { | ||
let res = {} | ||
for (let attrib of errorAttribs) | ||
if ( err[ attrib ] ) | ||
res[ attrib ] = err[attrib] | ||
res.message = err.message || err.toString() | ||
return res | ||
} | ||
function buildError (obj) { | ||
let error = new Error('') | ||
for (let attrib of errorAttribs) | ||
if ( obj[ attrib ] ) | ||
error[ attrib ] = obj[attrib] | ||
return error | ||
} | ||
amqpbarrel.randomNodeID = function ( valve, division, entityName ) { | ||
@@ -243,3 +262,3 @@ if ( _.isNumber( valve ) ) return valve | ||
let responses = comm.responseComms.map(function (c) { return Communication.importCommunication( c ) }) | ||
await self.appease( realComm, comm.err ? new Error(comm.err) : null, responses ) | ||
await self.appease( realComm, comm.err ? buildError(comm.err) : null, responses ) | ||
} | ||
@@ -281,6 +300,7 @@ return 'ok' | ||
self.logger.harconlog( null, 'Packet sending', {comm: comm, err: err ? err.message || err.toString() : null, responseComms: responseComms}, 'trace' ) | ||
let error = err ? printError(err) : null | ||
self.logger.harconlog( null, 'Packet sending', {comm: comm, err: error, responseComms: responseComms}, 'trace' ) | ||
let entityName = comm.source // event.substring(0, comm.event.indexOf('.') ) | ||
let packet = JSON.stringify( { id: comm.id, comm: comm, err: err ? err.message || err.toString() : null, response: true, responseComms: responseComms || [] } ) | ||
let packet = JSON.stringify( { id: comm.id, comm: comm, err: error, response: true, responseComms: responseComms || [] } ) | ||
let nodeNO = comm.sourceNodeID || self.randomNodeID( comm.valve, comm.sourceDivision, entityName ) | ||
@@ -287,0 +307,0 @@ self.outs[ comm.sourceDivision ].publish( entityName + (nodeNO ? (SEPARATOR + nodeNO) : ''), packet, 'utf8') |
{ | ||
"name": "harcon-amqp", | ||
"version": "9.1.1", | ||
"version": "9.1.2", | ||
"description": "AMQP plugin for the harcon messaging/service bus of node-based enterprise entities.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39457
998