3 new revisions:
Revision: d8cb9d395f15
Author: gdusbabek <gdusba...@gmail.com>
Date: Fri Oct 28 09:39:13 2011
Log: better/uniform error messages
http://code.google.com/a/apache-extras.org/p/cassandra-node/source/detail?r=d8cb9d395f15
Revision: 6cd84621b8ff
Author: gdusbabek <gdusba...@gmail.com>
Date: Fri Oct 28 13:57:55 2011
Log: fixes to make work with thrift 0.7
http://code.google.com/a/apache-extras.org/p/cassandra-node/source/detail?r=6cd84621b8ff
Revision: 7fc2478451ee
Author: gdusbabek <gdusba...@gmail.com>
Date: Fri Oct 28 14:35:49 2011
Log: bump package to 0.5.0 and thrift dep to 0.6.0-1
http://code.google.com/a/apache-extras.org/p/cassandra-node/source/detail?r=7fc2478451ee
==============================================================================
Revision: d8cb9d395f15
Author: gdusbabek <gdusba...@gmail.com>
Date: Fri Oct 28 09:39:13 2011
Log: better/uniform error messages
http://code.google.com/a/apache-extras.org/p/cassandra-node/source/detail?r=d8cb9d395f15
Modified:
/lib/driver.js
/test/test_driver.js
=======================================
--- /lib/driver.js Thu Oct 27 10:23:13 2011
+++ /lib/driver.js Fri Oct 28 09:39:13 2011
@@ -111,6 +111,17 @@
UUID = module.exports.UUID = require('./uuid').UUID;
+/** make sure that err.message is set to something that makes sense. */
+function amendError(err) {
+ if (!err.message || err.message.length === 0) {
+ if (err.name === "NotFoundException") {
+ err.message = "ColumnFamily or Keyspace does not exist";
+ } else if (err.why) {
+ err.message = err.why;
+ }
+ }
+ return err;
+}
/** abstraction of a single row. */
Row = module.exports.Row = function(row, decoder) {
@@ -266,7 +277,7 @@
self.pool.acquire(function(err, conn) {
if (err) {
log.err("Unable to acquire connection from the pool: " +
err.toString());
- callback(err);
+ callback(amendError(err));
} else {
conn.execute(query, args, function(err, res) {
if (err) {
@@ -331,6 +342,7 @@
Connection.prototype.connect = function(callback) {
var self = this;
this.con.on('error', function(err) {
+ amendError(err);
callback(err);
});
this.con.on('close', function() {
@@ -344,6 +356,7 @@
if (self.connectionInfo.user || self.connectionInfo.pass) {
var creds = new ttypes.AuthenticationRequest({user:
self.connectionInfo.user, password: self.connectionInfo.pass});
self.client.login(creds, function(err) {
+ if (err) { amendError(err); }
cb(err);
});
} else {
@@ -355,6 +368,7 @@
var learn = function(cb) {
self.client.describe_keyspace(self.connectionInfo.keyspace,
function(err, def) {
if (err) {
+ amendError(err);
cb(err);
} else {
for (var i = 0; i < def.cf_defs.length; i++) {
@@ -379,6 +393,7 @@
// 3) set the keyspace on the server.
var use = function(cb) {
self.client.set_keyspace(self.connectionInfo.keyspace, function(err)
{
+ if (err) { amendError(err); }
cb(err);
});
};
@@ -440,6 +455,7 @@
var self = this;
this.client.execute_cql_query(cql, ttypes.Compression.NONE,
function(err, res) {
if (err) {
+ amendError(err);
callback(err, null);
} else if (!res) {
callback(new Error('No results'), null);
=======================================
--- /test/test_driver.js Thu Oct 27 10:50:32 2011
+++ /test/test_driver.js Fri Oct 28 09:39:13 2011
@@ -213,7 +213,8 @@
exports.testConnectionKeyspaceDoesNotExistConnect = function(test, assert)
{
connect({keyspace: 'doesnotexist.'}, function(err, conn) {
assert.ok(err);
- assert.equal(err.toString(), 'NotFoundException');
+ assert.equal(err.name, 'NotFoundException')
+ assert.equal(err.message, 'ColumnFamily or Keyspace does not exist');
assert.ok(!conn);
test.finish();
});
@@ -225,7 +226,8 @@
use_bigints: false});
con.execute('SELECT * FROM foo', [], function(err) {
assert.ok(err);
- assert.equal(err.toString(), 'NotFoundException');
+ assert.equal(err.name, 'NotFoundException')
+ assert.equal(err.message, 'ColumnFamily or Keyspace does not exist');
test.finish();
});
};
==============================================================================
Revision: 6cd84621b8ff
Author: gdusbabek <gdusba...@gmail.com>
Date: Fri Oct 28 13:57:55 2011
Log: fixes to make work with thrift 0.7
http://code.google.com/a/apache-extras.org/p/cassandra-node/source/detail?r=6cd84621b8ff
Modified:
/lib/uuid.js
/package.json
/test/test_driver.js
=======================================
--- /lib/uuid.js Thu Apr 21 11:14:24 2011
+++ /lib/uuid.js Fri Oct 28 13:57:55 2011
@@ -53,11 +53,20 @@
return str;
}
+function byteAt(stringOrBuffer, i) {
+ if (Buffer.isBuffer(stringOrBuffer)) {
+ return stringOrBuffer[i];
+ } else {
+ return stringOrBuffer.charCodeAt(i);
+ }
+}
+
+
/** @binaryString is a string of bytes. this is how binary data comes to
us from cassandra. */
function makeInts(binaryString) {
var ints = [];
for (var i = 0; i < binaryString.length; i++) {
- ints[i] = binaryString.charCodeAt(i);
+ ints[i] = byteAt(binaryString, i);
if (ints[i] > 255 || ints[i] < 0) {
throw new Error('Unexpected byte in binary data.');
}
=======================================
--- /package.json Thu Oct 27 11:29:37 2011
+++ /package.json Fri Oct 28 13:57:55 2011
@@ -23,6 +23,7 @@
"node": ">= 0.4.0"
},
"dependencies" : {
+ "async": ">= 0.1.12",
"thrift" : ">= 0.6.0",
"logmagic": ">= 0.1.1",
"generic-pool" : ">= 1.0.7",
=======================================
--- /test/test_driver.js Fri Oct 28 09:39:13 2011
+++ /test/test_driver.js Fri Oct 28 13:57:55 2011
@@ -192,8 +192,8 @@
assert.ifError(selectErr);
assert.strictEqual(rows.rowCount(), 1);
var row = rows[0];
- assert.strictEqual('cola', row.cols[0].name);
- assert.strictEqual('valuea', row.cols[0].value);
+ assert.strictEqual('cola', row.cols[0].name.toString());
+ assert.strictEqual('valuea', row.cols[0].value.toString());
test.finish();
});
}
@@ -673,7 +673,7 @@
assert.ok(row.colHash.normal.equals(new BigInteger('25')));
assert.ok(row.colHash.int_col.equals(new BigInteger('21')));
- assert.ok(row.colHash.string_col === 'test_string_value');
+ assert.ok(row.colHash.string_col.toString()
=== 'test_string_value');
assert.ok(row.colHash.uuid_col.toString()
== '6f8483b0-65e0-11e0-0000-fe8ebeead9fe');
}
test.finish();
@@ -786,7 +786,7 @@
if (err) { bail(conn, err); }
assert.strictEqual(rows.rowCount(), 1);
var row = rows[0];
- assert.strictEqual(row.cols[0].name, 'A');
+ assert.strictEqual(row.cols[0].name.toString(), 'A');
});
}
==============================================================================
Revision: 7fc2478451ee
Author: gdusbabek <gdusba...@gmail.com>
Date: Fri Oct 28 14:35:49 2011
Log: bump package to 0.5.0 and thrift dep to 0.6.0-1
http://code.google.com/a/apache-extras.org/p/cassandra-node/source/detail?r=7fc2478451ee
Modified:
/package.json
=======================================
--- /package.json Fri Oct 28 13:57:55 2011
+++ /package.json Fri Oct 28 14:35:49 2011
@@ -6,7 +6,7 @@
],
"name": "cassandra-client",
"description": "Node.js CQL driver for Apache Cassandra",
- "version": "0.4.3",
+ "version": "0.5.0",
"homepage": "https://github.com/racker/node-cassandra-client",
"repository": {
"type": "git",
@@ -24,7 +24,7 @@
},
"dependencies" : {
"async": ">= 0.1.12",
- "thrift" : ">= 0.6.0",
+ "thrift" : ">= 0.6.0-1",
"logmagic": ">= 0.1.1",
"generic-pool" : ">= 1.0.7",
"whiskey": ">= 0.3.0"