postwait/node-amqp — Issue #70: passive:false catch exception
Author: rschiavi
Created: 2012-02-27 19:58:19+00:00
State: open

I'm using {passive:false} to test if a queue exists. As expected, if the queue doesn't exist, I get an exception. However, it's not "catchable". Shouldn't this error be caught on the connection object if connection.on('error. . .is setup?

var amqp = require('amqp');
var connection = null;

var get_connection = function(cb) {
if (connection === null) {
connection = amqp.createConnection({host: "localhost"});
connection.on('ready', function() {
console.log('ready');
connection.exchange("mog");
cb(connection);
});
connection.on('error', function(e) {
console.log("error: " + e);
log.error("---->AMQP connection closed");
connection = null;
});
connection.on('end', function() {
connection = null;
});
connection.on('close', function(){
console.log("closed");
});
}
else {
cb(connection);
}
};

get_connection(function(conn){
conn.queue("foo2", {'passive':true},function(q){
console.log(q);
});
});

process.on("uncaughtException", function(e){
// caught here
console.log(e);
});

Error: NOT_FOUND - no queue 'foo2' in vhost '/'
at Queue._onMethod (/Users/rich/dev/foo/foojs/node_modules/amqp/amqp.js:1703:15)
at Queue._onChannelMethod (/Users/rich/dev/foo/foojs/node_modules/amqp/amqp.js:1348:14)
at Connection._onMethod (/Users/rich/dev/foo/foojs/node_modules/amqp/amqp.js:917:28)
at AMQPParser.onMethod (/Users/rich/dev/foo/foojs/node_modules/amqp/amqp.js:792:12)
at AMQPParser._parseMethodFrame (/Users/rich/dev/foo/foojs/node_modules/amqp/amqp.js:441:10)
at frameEnd (/Users/rich/dev/foo/foojs/node_modules/amqp/amqp.js:186:16)
at frame (/Users/rich/dev/foo/foojs/node_modules/amqp/amqp.js:171:14)
at AMQPParser.header [as parse] (/Users/rich/dev/foo/foojs/node_modules/amqp/amqp.js:159:14)
at AMQPParser.execute (/Users/rich/dev/foo/foojs/node_modules/amqp/amqp.js:230:21)
at Connection. (/Users/rich/dev/foo/foojs/node_modules/amqp/amqp.js:832:12)