grncdr/node-any-db-pool — pull request #10 by vickvu (2014-02-12 06:11:55+00:00)
Title: Tentative PR for error handling

@grncdr, this is my proposed change, the client code would look like this example
```javascript
//Create a database pool
var pool = anydb.createPool(connectionString);
pool.on("error", function(err, conn) {
console.log("Pool error" + err);
});
//Using a pool
pool.query("SELECT * FROM status", function(err, result) {
if (err) {
//Error happens, destroy the connection
pool.destroy(err.connection);
} else {
//Process the result
}
});
```
In my current project, I would like to destroy the connection when error happens with the query. However, I think other people may want to keep their connection alive. Also with postgres, I can do something like this
```javascript
pool.query("SELECT * FROM status", function(err, result) {
if (err) {
//Only destroy the connection if the error is serious
if (err.severity == "FATAL") {
pool.destroy(err.connection);
}
} else {
//Process the result
}
});
```
What do you think?