Permalink
Browse files

Handle errory connection string

  • Loading branch information...
timoxley committed Feb 8, 2012
1 parent 1f24314 commit 7c20db75791bf431e3030f6a6d51ec85caf7e8ff
Showing with 16 additions and 0 deletions.
  1. +4 −0 index.js
  2. +12 −0 test/error.js
View
@@ -100,6 +100,10 @@ dnode.prototype.connect = function () {
}
function attachDnode() {
+ if (!stream) {
+ self.emit('error', new Error('Could not create a stream with this information ' + JSON.stringify(params)))
+ return null
+ }
client = createClient(self.proto, stream);
client.end = function () {
View
@@ -85,3 +85,15 @@ test('refused', function (t) {
t.end();
});
});
+
+
+test('bad connection string', function(t) {
+ try {
+ var client = dnode.connect('garbage', function (remote, conn) {
+ assert.fail('should have been refused, very unlikely');
+ });
+ } catch (err) {
+ t.ok(/Could not create a stream/.test(err.message));
+ t.end();
+ }
+});

0 comments on commit 7c20db7

Please sign in to comment.