amqp-as-promised
Advanced tools
Comparing version 3.0.2 to 4.0.0
Changelog | ||
========= | ||
## 4.0.0 - 2016-11-18 | ||
* Improved error handling: | ||
1. `RpcBackend.serve()` will now serialize errors in a slightly different | ||
format, preserving `message`, `code` and `errno` if present in | ||
the error object. | ||
2. `Rpc.rpc()` will treat any return message that is a JSON object | ||
containing an `error` property as a remote error, resulting in a | ||
rejected promise. Previously we didn't care to inspect return | ||
messages, so remote errors would still yield fulfilled promises. | ||
## 3.0.2 - 2016-11-08 | ||
@@ -5,0 +16,0 @@ |
@@ -59,3 +59,6 @@ // Generated by CoffeeScript 1.11.1 | ||
RpcBackend.prototype._mkcallback = function(exchange, handler, subopts) { | ||
RpcBackend.prototype._mkcallback = function(exchange, handler, subopts, serializeError) { | ||
if (serializeError == null) { | ||
serializeError = require('./error-serializer'); | ||
} | ||
return function(msg, headers, info, ack) { | ||
@@ -98,6 +101,3 @@ return doack(subopts, ack)(function() { | ||
return Promise.resolve().then(function() { | ||
var ref3; | ||
return exchange.publish(info.replyTo, { | ||
error: (ref3 = err.message) != null ? ref3 : err | ||
}, opts); | ||
return exchange.publish(info.replyTo, serializeError(err), opts); | ||
}).then(function() { | ||
@@ -104,0 +104,0 @@ if (subopts != null ? subopts.ack : void 0) { |
@@ -55,4 +55,10 @@ // Generated by CoffeeScript 1.11.1 | ||
Rpc.prototype.registerResponse = function(corrId, options) { | ||
Rpc.prototype.registerResponse = function(corrId, options, deserialize) { | ||
var def, value; | ||
if (options == null) { | ||
options = {}; | ||
} | ||
if (deserialize == null) { | ||
deserialize = require('./error-deserializer'); | ||
} | ||
def = {}; | ||
@@ -63,6 +69,6 @@ def.promise = new Promise(function(resolve, reject) { | ||
}); | ||
options = options || {}; | ||
value = { | ||
def: def, | ||
options: options | ||
options: options, | ||
deserialize: deserialize | ||
}; | ||
@@ -80,3 +86,3 @@ this.responses.set(corrId, value, options.timeout); | ||
_this.responses.remove(corrId); | ||
return response.def.resolve(payload); | ||
return response.def.resolve(response.deserialize(payload)); | ||
}; | ||
@@ -83,0 +89,0 @@ })(this))["catch"](function(err) { |
{ | ||
"name": "amqp-as-promised", | ||
"description": "A promise-based AMQP API build on node-amqp", | ||
"version": "3.0.2", | ||
"version": "4.0.0", | ||
"repository": { | ||
@@ -32,10 +32,11 @@ "type": "git", | ||
"devDependencies": { | ||
"chai": "^3.4.1", | ||
"chai-as-promised": "^5.2.0", | ||
"coffee-script": "^1.10.0", | ||
"mocha": "^2.3.4", | ||
"chai": "^3.5.0", | ||
"chai-as-promised": "^6.0.0", | ||
"chai-like": "^0.1.10", | ||
"coffee-script": "^1.11.1", | ||
"mocha": "^3.1.2", | ||
"proxyquire": "^1.7.3", | ||
"sinon": "~1.17.2", | ||
"sinon": "^1.17.6", | ||
"sinon-chai": "^2.8.0" | ||
} | ||
} |
@@ -193,4 +193,12 @@ AMQP as Promised | ||
If an exception is thrown by the handler, it will be propagated back | ||
to the client as an object with a `error` property containing the | ||
error message. | ||
to the client as an object: | ||
``` | ||
{ | ||
"error": { | ||
"message": <exception.message>, | ||
[ "code": <exception.code>, ] | ||
[ "errno": <exception.errno> ] | ||
} | ||
} | ||
``` | ||
@@ -316,3 +324,5 @@ ### Serve with prefetchCount/ack | ||
with the contents of the reply. If no reply is received before the | ||
timeout, the promise is instead rejected. | ||
timeout, the promise is instead rejected. Replies that are JSON | ||
objects that have an `error` property set are assumed to be remote | ||
errors, and will result in a rejected promise. | ||
@@ -319,0 +329,0 @@ #### Parameters |
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
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
42
826
352
106622
8