Permalink
Browse files

Node v0.3.0 compatibility fix

  • Loading branch information...
1 parent f7a109b commit 2ee3837297fa7de0e73c5d0b92e74ee030b3cc34 @devioustree devioustree committed Dec 22, 2010
Showing with 6 additions and 3 deletions.
  1. +6 −3 lib/couch-client.js
View
@@ -9,6 +9,9 @@ var Http = require('http'),
var POOL_SIZE = 200; // Maximum number of concurrent connections allowed.
var MAX_DOCS = 1000; // The maximum number of docs to send in a single batch
+// Handles changes made in node v0.3.0
+var NOT_FOUND_ERR_NO = process.ENOENT ? process.ENOENT : require('constants').ENOENT;
+
function noOp(err) { if (err) { throw err; } }
var pool = new Array(POOL_SIZE);
@@ -141,7 +144,7 @@ function CouchClient(url) {
request("POST", uri.pathname + "/_bulk_docs", {docs: body}, function (err, results) {
if (results.error) {
err = new Error("CouchDB Error: " + JSON.stringify(results));
- if (results.error === 'not_found') { err.errno = process.ENOENT; }
+ if (results.error === 'not_found') { err.errno = NOT_FOUND_ERR_NO; }
}
if (err) {
pending.forEach(function (callback) {
@@ -189,13 +192,13 @@ function CouchClient(url) {
if (includeDoc) {
if (result.error) {
err = new Error("CouchDB Error: " + JSON.stringify(result));
- if (result.error === 'not_found') { err.errno = process.ENOENT; }
+ if (result.error === 'not_found') { err.errno = NOT_FOUND_ERR_NO; }
pending[i](err);
return;
}
if (!result.doc) {
err = new Error("Document not found for " + JSON.stringify(result.key));
- err.errno = process.ENOENT;
+ err.errno = NOT_FOUND_ERR_NO;
pending[i](err);
return;
}

0 comments on commit 2ee3837

Please sign in to comment.