Comparing version 0.5.6 to 0.5.7
@@ -382,4 +382,5 @@ var sys = require('sys'); | ||
//parses error | ||
p.parseE = function(msg) { | ||
p.parseE = function(input) { | ||
var fields = {}; | ||
var msg, item; | ||
var fieldType = this.readString(1); | ||
@@ -390,5 +391,18 @@ while(fieldType != '\0') { | ||
} | ||
if (input.name === 'error') { | ||
// the msg is an Error instance | ||
msg = new Error(fields.M); | ||
for (item in input) { | ||
// copy input properties to the error | ||
if (input.hasOwnProperty(item)) { | ||
msg[item] = input[item]; | ||
} | ||
} | ||
} else { | ||
// the msg is an object literal | ||
msg = input; | ||
msg.message = fields.M; | ||
} | ||
msg.severity = fields.S; | ||
msg.code = fields.C; | ||
msg.message = fields.M; | ||
msg.detail = fields.D; | ||
@@ -395,0 +409,0 @@ msg.hint = fields.H; |
{ "name": "pg", | ||
"version": "0.5.6", | ||
"version": "0.5.7", | ||
"description": "PostgreSQL client - pure javascript & libpq with the same API", | ||
@@ -4,0 +4,0 @@ "keywords" : ["postgres", "pg", "libpq", "postgre", "database", "rdbms"], |
@@ -115,2 +115,3 @@ #node-postgres | ||
* [neonstalwart](https://github.com/neonstalwart) | ||
* [homme](https://github.com/homme) | ||
@@ -117,0 +118,0 @@ ## Documentation |
@@ -20,4 +20,4 @@ var helper = require(__dirname + "/../test-helper"); | ||
assert.ok(error); | ||
assert.ok(client); | ||
assert.equal(client.id, 1); | ||
assert.ok(brokenClient); | ||
assert.equal(client.id, brokenClient.id); | ||
pg.end(); | ||
@@ -24,0 +24,0 @@ }); |
@@ -38,2 +38,7 @@ //make assert a global... | ||
item.once(eventName, function() { | ||
if (eventName === 'error') { | ||
// belt and braces test to ensure all error events return an error | ||
assert.ok(arguments[0] instanceof Error, | ||
"Expected error events to throw instances of Error but found: " + sys.inspect(arguments[0])); | ||
} | ||
called = true; | ||
@@ -109,2 +114,3 @@ clearTimeout(id); | ||
} catch (e) { | ||
assert.ok(e instanceof Error, "Expected " + offender + " to throw instances of Error"); | ||
return; | ||
@@ -122,3 +128,3 @@ } | ||
var id = setTimeout(function() { | ||
assert.ok(executed, "Expected execution of funtion to be fired"); | ||
assert.ok(executed, "Expected execution of function to be fired"); | ||
}, timeout || 2000) | ||
@@ -128,3 +134,5 @@ | ||
clearTimeout(id); | ||
assert.ok(true); | ||
if (err) { | ||
assert.ok(err instanceof Error, "Expected errors to be instances of Error: " + sys.inspect(err)); | ||
} | ||
callback.apply(this, arguments) | ||
@@ -131,0 +139,0 @@ } |
@@ -6,6 +6,6 @@ var helper = require(__dirname + '/test-helper'); | ||
assert.emits(con, 'error', function(err) { | ||
assert.equal(err, "OMG!"); | ||
assert.equal(err.message, "OMG!"); | ||
}); | ||
con.connect(); | ||
con.stream.emit('error', "OMG!"); | ||
con.stream.emit('error', new Error("OMG!")); | ||
}); |
Sorry, the diff of this file is not supported yet
193752
5159
160