Comparing version 2.0.2 to 2.1.0
@@ -70,9 +70,9 @@ // Generated by CoffeeScript 1.7.0 | ||
case protoResponseType.COMPILE_ERROR: | ||
this._closeCb(mkErr(err.RqlRuntimeError, response, this._root)); | ||
this._closeCb(mkErr(err.ReqlCompileError, response, this._root)); | ||
break; | ||
case protoResponseType.CLIENT_ERROR: | ||
this._closeCb(mkErr(err.RqlRuntimeError, response, this._root)); | ||
this._closeCb(mkErr(err.ReqlClientError, response, this._root)); | ||
break; | ||
case protoResponseType.RUNTIME_ERROR: | ||
this._closeCb(mkErr(err.RqlRuntimeError, response, this._root)); | ||
this._closeCb(mkErr(util.errorClass(response.e), response, this._root)); | ||
break; | ||
@@ -127,3 +127,3 @@ default: | ||
IterableResult.prototype._promptNext = function() { | ||
var cb, response; | ||
var cb, errType, response; | ||
while (this._cbQueue[0] != null) { | ||
@@ -133,3 +133,3 @@ if (this.bufferEmpty() === true) { | ||
cb = this._getCallback(); | ||
cb(new err.RqlDriverError("No more rows in the cursor.")); | ||
cb(new err.ReqlDriverError("No more rows in the cursor.")); | ||
} else if (this._responses.length <= 1) { | ||
@@ -158,3 +158,3 @@ this._promptCont(); | ||
cb = this._getCallback(); | ||
cb(mkErr(err.RqlCompileError, response, this._root)); | ||
cb(mkErr(err.ReqlCompileError, response, this._root)); | ||
break; | ||
@@ -164,3 +164,3 @@ case protoResponseType.CLIENT_ERROR: | ||
cb = this._getCallback(); | ||
cb(mkErr(err.RqlClientError, response, this._root)); | ||
cb(mkErr(err.ReqlClientError, response, this._root)); | ||
break; | ||
@@ -170,3 +170,4 @@ case protoResponseType.RUNTIME_ERROR: | ||
cb = this._getCallback(); | ||
cb(mkErr(err.RqlRuntimeError, response, this._root)); | ||
errType = util.errorClass(response.e); | ||
cb(mkErr(errType, response, this._root)); | ||
break; | ||
@@ -176,3 +177,3 @@ default: | ||
cb = this._getCallback(); | ||
cb(new err.RqlDriverError("Unknown response type for cursor")); | ||
cb(new err.ReqlDriverError("Unknown response type for cursor")); | ||
} | ||
@@ -192,3 +193,3 @@ } | ||
IterableResult.prototype.hasNext = function() { | ||
throw new err.RqlDriverError("The `hasNext` command has been removed since 1.13. Use `next` instead."); | ||
throw new err.ReqlDriverError("The `hasNext` command has been removed since 1.13. Use `next` instead."); | ||
}; | ||
@@ -219,3 +220,3 @@ | ||
} else { | ||
throw new err.RqlDriverError("First argument to `next` must be a function or undefined."); | ||
throw new err.ReqlDriverError("First argument to `next` must be a function or undefined."); | ||
} | ||
@@ -261,6 +262,6 @@ }); | ||
if (typeof cb !== 'function') { | ||
throw new err.RqlDriverError("First argument to each must be a function."); | ||
throw new err.ReqlDriverError("First argument to each must be a function."); | ||
} | ||
if ((onFinished != null) && typeof onFinished !== 'function') { | ||
throw new err.RqlDriverError("Optional second argument to each must be a function."); | ||
throw new err.ReqlDriverError("Optional second argument to each must be a function."); | ||
} | ||
@@ -312,3 +313,3 @@ stopFlag = false; | ||
if ((cb != null) && typeof cb !== 'function') { | ||
throw new err.RqlDriverError("First argument to `toArray` must be a function or undefined."); | ||
throw new err.ReqlDriverError("First argument to `toArray` must be a function or undefined."); | ||
} | ||
@@ -333,6 +334,6 @@ return new Promise((function(_this) { | ||
this.each = function() { | ||
throw new err.RqlDriverError("You cannot use the cursor interface and the EventEmitter interface at the same time."); | ||
throw new err.ReqlDriverError("You cannot use the cursor interface and the EventEmitter interface at the same time."); | ||
}; | ||
return this.next = function() { | ||
throw new err.RqlDriverError("You cannot use the cursor interface and the EventEmitter interface at the same time."); | ||
throw new err.ReqlDriverError("You cannot use the cursor interface and the EventEmitter interface at the same time."); | ||
}; | ||
@@ -476,7 +477,7 @@ }; | ||
Feed.prototype.hasNext = function() { | ||
throw new err.RqlDriverError("`hasNext` is not available for feeds."); | ||
throw new err.ReqlDriverError("`hasNext` is not available for feeds."); | ||
}; | ||
Feed.prototype.toArray = function() { | ||
throw new err.RqlDriverError("`toArray` is not available for feeds."); | ||
throw new err.ReqlDriverError("`toArray` is not available for feeds."); | ||
}; | ||
@@ -501,7 +502,7 @@ | ||
UnionedFeed.prototype.hasNext = function() { | ||
throw new err.RqlDriverError("`hasNext` is not available for feeds."); | ||
throw new err.ReqlDriverError("`hasNext` is not available for feeds."); | ||
}; | ||
UnionedFeed.prototype.toArray = function() { | ||
throw new err.RqlDriverError("`toArray` is not available for feeds."); | ||
throw new err.ReqlDriverError("`toArray` is not available for feeds."); | ||
}; | ||
@@ -526,7 +527,7 @@ | ||
AtomFeed.prototype.hasNext = function() { | ||
throw new err.RqlDriverError("`hasNext` is not available for feeds."); | ||
throw new err.ReqlDriverError("`hasNext` is not available for feeds."); | ||
}; | ||
AtomFeed.prototype.toArray = function() { | ||
throw new err.RqlDriverError("`toArray` is not available for feeds."); | ||
throw new err.ReqlDriverError("`toArray` is not available for feeds."); | ||
}; | ||
@@ -551,7 +552,7 @@ | ||
OrderByLimitFeed.prototype.hasNext = function() { | ||
throw new err.RqlDriverError("`hasNext` is not available for feeds."); | ||
throw new err.ReqlDriverError("`hasNext` is not available for feeds."); | ||
}; | ||
OrderByLimitFeed.prototype.toArray = function() { | ||
throw new err.RqlDriverError("`toArray` is not available for feeds."); | ||
throw new err.ReqlDriverError("`toArray` is not available for feeds."); | ||
}; | ||
@@ -596,3 +597,3 @@ | ||
} else { | ||
return cb(new err.RqlDriverError("No more rows in the cursor.")); | ||
return cb(new err.ReqlDriverError("No more rows in the cursor.")); | ||
} | ||
@@ -599,0 +600,0 @@ }; |
200
errors.js
// Generated by CoffeeScript 1.7.0 | ||
var RqlClientError, RqlCompileError, RqlDriverError, RqlQueryPrinter, RqlRuntimeError, RqlServerError, | ||
var ReqlAuthError, ReqlAvailabilityError, ReqlCompileError, ReqlDriverError, ReqlError, ReqlInternalError, ReqlNonExistenceError, ReqlOpFailedError, ReqlOpIndeterminateError, ReqlQueryLogicError, ReqlQueryPrinter, ReqlResourceLimitError, ReqlRuntimeError, ReqlTimeoutError, ReqlUserError, | ||
__hasProp = {}.hasOwnProperty, | ||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
RqlDriverError = (function(_super) { | ||
__extends(RqlDriverError, _super); | ||
ReqlError = (function(_super) { | ||
__extends(ReqlError, _super); | ||
function RqlDriverError(msg) { | ||
function ReqlError(msg) { | ||
this.name = this.constructor.name; | ||
@@ -18,10 +18,43 @@ this.msg = msg; | ||
return RqlDriverError; | ||
return ReqlError; | ||
})(Error); | ||
RqlServerError = (function(_super) { | ||
__extends(RqlServerError, _super); | ||
ReqlCompileError = (function(_super) { | ||
__extends(ReqlCompileError, _super); | ||
function RqlServerError(msg, term, frames) { | ||
function ReqlCompileError() { | ||
return ReqlCompileError.__super__.constructor.apply(this, arguments); | ||
} | ||
return ReqlCompileError; | ||
})(ReqlError); | ||
ReqlDriverError = (function(_super) { | ||
__extends(ReqlDriverError, _super); | ||
function ReqlDriverError() { | ||
return ReqlDriverError.__super__.constructor.apply(this, arguments); | ||
} | ||
return ReqlDriverError; | ||
})(ReqlError); | ||
ReqlAuthError = (function(_super) { | ||
__extends(ReqlAuthError, _super); | ||
function ReqlAuthError() { | ||
return ReqlAuthError.__super__.constructor.apply(this, arguments); | ||
} | ||
return ReqlAuthError; | ||
})(ReqlDriverError); | ||
ReqlRuntimeError = (function(_super) { | ||
__extends(ReqlRuntimeError, _super); | ||
function ReqlRuntimeError(msg, term, frames) { | ||
this.name = this.constructor.name; | ||
@@ -32,5 +65,5 @@ this.msg = msg; | ||
if (msg[msg.length - 1] === '.') { | ||
this.message = "" + (msg.slice(0, msg.length - 1)) + " in:\n" + (RqlQueryPrinter.prototype.printQuery(term)) + "\n" + (RqlQueryPrinter.prototype.printCarrots(term, frames)); | ||
this.message = "" + (msg.slice(0, msg.length - 1)) + " in:\n" + (ReqlQueryPrinter.prototype.printQuery(term)) + "\n" + (ReqlQueryPrinter.prototype.printCarrots(term, frames)); | ||
} else { | ||
this.message = "" + msg + " in:\n" + (RqlQueryPrinter.prototype.printQuery(term)) + "\n" + (RqlQueryPrinter.prototype.printCarrots(term, frames)); | ||
this.message = "" + msg + " in:\n" + (ReqlQueryPrinter.prototype.printQuery(term)) + "\n" + (ReqlQueryPrinter.prototype.printCarrots(term, frames)); | ||
} | ||
@@ -45,45 +78,111 @@ } else { | ||
return RqlServerError; | ||
return ReqlRuntimeError; | ||
})(Error); | ||
})(ReqlError); | ||
RqlRuntimeError = (function(_super) { | ||
__extends(RqlRuntimeError, _super); | ||
ReqlQueryLogicError = (function(_super) { | ||
__extends(ReqlQueryLogicError, _super); | ||
function RqlRuntimeError() { | ||
return RqlRuntimeError.__super__.constructor.apply(this, arguments); | ||
function ReqlQueryLogicError() { | ||
return ReqlQueryLogicError.__super__.constructor.apply(this, arguments); | ||
} | ||
return RqlRuntimeError; | ||
return ReqlQueryLogicError; | ||
})(RqlServerError); | ||
})(ReqlRuntimeError); | ||
RqlCompileError = (function(_super) { | ||
__extends(RqlCompileError, _super); | ||
ReqlNonExistenceError = (function(_super) { | ||
__extends(ReqlNonExistenceError, _super); | ||
function RqlCompileError() { | ||
return RqlCompileError.__super__.constructor.apply(this, arguments); | ||
function ReqlNonExistenceError() { | ||
return ReqlNonExistenceError.__super__.constructor.apply(this, arguments); | ||
} | ||
return RqlCompileError; | ||
return ReqlNonExistenceError; | ||
})(RqlServerError); | ||
})(ReqlQueryLogicError); | ||
RqlClientError = (function(_super) { | ||
__extends(RqlClientError, _super); | ||
ReqlResourceLimitError = (function(_super) { | ||
__extends(ReqlResourceLimitError, _super); | ||
function RqlClientError() { | ||
return RqlClientError.__super__.constructor.apply(this, arguments); | ||
function ReqlResourceLimitError() { | ||
return ReqlResourceLimitError.__super__.constructor.apply(this, arguments); | ||
} | ||
return RqlClientError; | ||
return ReqlResourceLimitError; | ||
})(RqlServerError); | ||
})(ReqlRuntimeError); | ||
RqlQueryPrinter = (function() { | ||
ReqlUserError = (function(_super) { | ||
__extends(ReqlUserError, _super); | ||
function ReqlUserError() { | ||
return ReqlUserError.__super__.constructor.apply(this, arguments); | ||
} | ||
return ReqlUserError; | ||
})(ReqlRuntimeError); | ||
ReqlInternalError = (function(_super) { | ||
__extends(ReqlInternalError, _super); | ||
function ReqlInternalError() { | ||
return ReqlInternalError.__super__.constructor.apply(this, arguments); | ||
} | ||
return ReqlInternalError; | ||
})(ReqlRuntimeError); | ||
ReqlTimeoutError = (function(_super) { | ||
__extends(ReqlTimeoutError, _super); | ||
function ReqlTimeoutError() { | ||
return ReqlTimeoutError.__super__.constructor.apply(this, arguments); | ||
} | ||
return ReqlTimeoutError; | ||
})(ReqlError); | ||
ReqlAvailabilityError = (function(_super) { | ||
__extends(ReqlAvailabilityError, _super); | ||
function ReqlAvailabilityError() { | ||
return ReqlAvailabilityError.__super__.constructor.apply(this, arguments); | ||
} | ||
return ReqlAvailabilityError; | ||
})(ReqlRuntimeError); | ||
ReqlOpFailedError = (function(_super) { | ||
__extends(ReqlOpFailedError, _super); | ||
function ReqlOpFailedError() { | ||
return ReqlOpFailedError.__super__.constructor.apply(this, arguments); | ||
} | ||
return ReqlOpFailedError; | ||
})(ReqlAvailabilityError); | ||
ReqlOpIndeterminateError = (function(_super) { | ||
__extends(ReqlOpIndeterminateError, _super); | ||
function ReqlOpIndeterminateError() { | ||
return ReqlOpIndeterminateError.__super__.constructor.apply(this, arguments); | ||
} | ||
return ReqlOpIndeterminateError; | ||
})(ReqlAvailabilityError); | ||
ReqlQueryPrinter = (function() { | ||
var carrotMarker, carrotify, composeCarrots, composeTerm, joinTree; | ||
function RqlQueryPrinter() {} | ||
function ReqlQueryPrinter() {} | ||
RqlQueryPrinter.prototype.printQuery = function(term) { | ||
ReqlQueryPrinter.prototype.printQuery = function(term) { | ||
var tree; | ||
@@ -116,3 +215,3 @@ tree = composeTerm(term); | ||
RqlQueryPrinter.prototype.printCarrots = function(term, frames) { | ||
ReqlQueryPrinter.prototype.printCarrots = function(term, frames) { | ||
var tree; | ||
@@ -186,14 +285,27 @@ if (frames.length === 0) { | ||
return RqlQueryPrinter; | ||
return ReqlQueryPrinter; | ||
})(); | ||
module.exports.RqlDriverError = RqlDriverError; | ||
module.exports.RqlRuntimeError = RqlRuntimeError; | ||
module.exports.RqlCompileError = RqlCompileError; | ||
module.exports.RqlClientError = RqlClientError; | ||
module.exports.printQuery = RqlQueryPrinter.prototype.printQuery; | ||
module.exports = { | ||
ReqlError: ReqlError, | ||
ReqlCompileError: ReqlCompileError, | ||
RqlCompileError: ReqlCompileError, | ||
RqlClientError: ReqlDriverError, | ||
ReqlRuntimeError: ReqlRuntimeError, | ||
RqlRuntimeError: ReqlRuntimeError, | ||
RqlServerError: ReqlRuntimeError, | ||
ReqlQueryLogicError: ReqlQueryLogicError, | ||
ReqlNonExistenceError: ReqlNonExistenceError, | ||
ReqlResourceLimitError: ReqlResourceLimitError, | ||
ReqlUserError: ReqlUserError, | ||
ReqlInternalError: ReqlInternalError, | ||
ReqlTimeoutError: ReqlTimeoutError, | ||
ReqlAvailabilityError: ReqlAvailabilityError, | ||
ReqlOpFailedError: ReqlOpFailedError, | ||
ReqlOpIndeterminateError: ReqlOpIndeterminateError, | ||
ReqlDriverError: ReqlDriverError, | ||
RqlDriverError: ReqlDriverError, | ||
ReqlAuthError: ReqlAuthError, | ||
printQuery: ReqlQueryPrinter.prototype.printQuery | ||
}; |
112
net.js
// Generated by CoffeeScript 1.7.0 | ||
var Connection, HttpConnection, Promise, TcpConnection, ar, aropt, cursors, err, events, mkAtom, mkErr, net, protoProtocol, protoQueryType, protoResponseType, protoVersion, protodef, r, util, varar, | ||
var Connection, HANDSHAKE_AUTHFAIL, HANDSHAKE_SUCCESS, HttpConnection, Promise, TcpConnection, ar, aropt, cursors, err, events, mkAtom, mkErr, net, protoProtocol, protoQueryType, protoResponseType, protoVersion, protodef, r, tls, util, varar, | ||
__hasProp = {}.hasOwnProperty, | ||
@@ -8,2 +8,4 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
tls = require('tls'); | ||
events = require('events'); | ||
@@ -41,2 +43,6 @@ | ||
HANDSHAKE_SUCCESS = "SUCCESS"; | ||
HANDSHAKE_AUTHFAIL = "ERROR: Incorrect authorization key.\n"; | ||
Connection = (function(_super) { | ||
@@ -67,2 +73,9 @@ __extends(Connection, _super); | ||
this.timeout = host.timeout || this.DEFAULT_TIMEOUT; | ||
if (typeof host.ssl === 'boolean' && host.ssl) { | ||
this.ssl = {}; | ||
} else if (typeof host.ssl === 'object') { | ||
this.ssl = host.ssl; | ||
} else { | ||
this.ssl = false; | ||
} | ||
this.outstandingCallbacks = {}; | ||
@@ -77,6 +90,6 @@ this.nextToken = 1; | ||
_this.removeListener('connect', conCallback); | ||
if (e instanceof err.RqlDriverError) { | ||
if (e instanceof err.ReqlError) { | ||
return callback(e); | ||
} else { | ||
return callback(new err.RqlDriverError("Could not connect to " + _this.host + ":" + _this.port + ".\n" + e.message)); | ||
return callback(new err.ReqlDriverError("Could not connect to " + _this.host + ":" + _this.port + ".\n" + e.message)); | ||
} | ||
@@ -120,3 +133,3 @@ }; | ||
Connection.prototype._processResponse = function(response, token) { | ||
var cb, cursor, feed, note, opts, profile, root, _i, _len, _ref, _ref1; | ||
var cb, cursor, errType, feed, note, opts, profile, root, _i, _len, _ref, _ref1; | ||
profile = response.p; | ||
@@ -133,9 +146,10 @@ if (this.outstandingCallbacks[token] != null) { | ||
case protoResponseType.COMPILE_ERROR: | ||
cb(mkErr(err.RqlCompileError, response, root)); | ||
cb(mkErr(err.ReqlCompileError, response, root)); | ||
return this._delQuery(token); | ||
case protoResponseType.CLIENT_ERROR: | ||
cb(mkErr(err.RqlClientError, response, root)); | ||
cb(mkErr(err.ReqlDriverError, response, root)); | ||
return this._delQuery(token); | ||
case protoResponseType.RUNTIME_ERROR: | ||
cb(mkErr(err.RqlRuntimeError, response, root)); | ||
errType = util.errorClass(response.e); | ||
cb(mkErr(errType, response, root)); | ||
return this._delQuery(token); | ||
@@ -211,3 +225,3 @@ case protoResponseType.SUCCESS_ATOM: | ||
default: | ||
return cb(new err.RqlDriverError("Unknown response type")); | ||
return cb(new err.ReqlDriverError("Unknown response type")); | ||
} | ||
@@ -225,3 +239,3 @@ } | ||
if (Object.prototype.toString.call(opts) !== '[object Object]') { | ||
throw new err.RqlDriverError("First argument to two-argument `close` must be an object."); | ||
throw new err.ReqlDriverError("First argument to two-argument `close` must be an object."); | ||
} | ||
@@ -242,3 +256,3 @@ cb = callback; | ||
if (key !== 'noreplyWait') { | ||
throw new err.RqlDriverError("First argument to two-argument `close` must be { noreplyWait: <bool> }."); | ||
throw new err.ReqlDriverError("First argument to two-argument `close` must be { noreplyWait: <bool> }."); | ||
} | ||
@@ -248,13 +262,2 @@ } | ||
return this._closePromise.nodeify(cb); | ||
} else if (!this.open) { | ||
return new Promise((function(_this) { | ||
return function(resolve, reject) { | ||
if (cb != null) { | ||
cb(null, _this); | ||
} else { | ||
} | ||
return process.nextTick(resolve); | ||
}; | ||
})(this)); | ||
} | ||
@@ -270,3 +273,2 @@ this.closing = true; | ||
_this.cancel(); | ||
_this._closePromise = null; | ||
if (err != null) { | ||
@@ -291,3 +293,3 @@ return reject(err); | ||
return new Promise(function(resolve, reject) { | ||
return reject(new err.RqlDriverError("Connection is closed.")); | ||
return reject(new err.ReqlDriverError("Connection is closed.")); | ||
}).nodeify(callback); | ||
@@ -333,3 +335,3 @@ } | ||
} else if (value.cb != null) { | ||
value.cb(mkErr(err.RqlRuntimeError, response, value.root)); | ||
value.cb(mkErr(util.errorClass(response.e), response, value.root)); | ||
} | ||
@@ -389,3 +391,3 @@ } | ||
if (!this.open) { | ||
throw new err.RqlDriverError("Connection is closed."); | ||
throw new err.ReqlDriverError("Connection is closed."); | ||
} | ||
@@ -403,8 +405,5 @@ token = this.nextToken++; | ||
} | ||
if (this.db != null) { | ||
query.global_optargs['db'] = r.db(this.db).build(); | ||
if ((opts.db != null) || (this.db != null)) { | ||
query.global_optargs.db = r.db(opts.db || this.db).build(); | ||
} | ||
if (opts.useOutdated != null) { | ||
query.global_optargs['use_outdated'] = r.expr(!!opts.useOutdated).build(); | ||
} | ||
if (opts.noreply != null) { | ||
@@ -432,3 +431,3 @@ query.global_optargs['noreply'] = r.expr(!!opts.noreply).build(); | ||
if (!this.open) { | ||
throw new err.RqlDriverError("Connection is closed."); | ||
throw new err.ReqlDriverError("Connection is closed."); | ||
} | ||
@@ -445,3 +444,3 @@ query = { | ||
if (!this.open) { | ||
throw new err.RqlDriverError("Connection is closed."); | ||
throw new err.ReqlDriverError("Connection is closed."); | ||
} | ||
@@ -481,11 +480,16 @@ query = { | ||
if (!TcpConnection.isAvailable()) { | ||
throw new err.RqlDriverError("TCP sockets are not available in this environment"); | ||
throw new err.ReqlDriverError("TCP sockets are not available in this environment"); | ||
} | ||
TcpConnection.__super__.constructor.call(this, host, callback); | ||
this.rawSocket = net.connect(this.port, this.host); | ||
if (this.ssl) { | ||
this.rawSocket = tls.connect(options); | ||
} else { | ||
this.rawSocket = net.connect(this.port, this.host); | ||
} | ||
this.rawSocket.setNoDelay(); | ||
this.rawSocket.setKeepAlive(true); | ||
timeout = setTimeout(((function(_this) { | ||
return function() { | ||
_this.rawSocket.destroy(); | ||
return _this.emit('error', new err.RqlDriverError("Handshake timedout")); | ||
return _this.emit('error', new err.ReqlTimeoutError("Could not connect to " + _this.host + ":" + _this.port + ", operation timed out.")); | ||
}; | ||
@@ -521,3 +525,3 @@ })(this)), this.timeout * 1000); | ||
clearTimeout(timeout); | ||
if (status_str === "SUCCESS") { | ||
if (status_str === HANDSHAKE_SUCCESS) { | ||
_this.rawSocket.on('data', function(buf) { | ||
@@ -528,4 +532,6 @@ return _this._data(buf); | ||
return; | ||
} else if (status_str === HANDSHAKE_AUTHFAIL) { | ||
_this.emit('error', new err.ReqlAuthError("Could not connect to " + _this.host + ":" + _this.port + ", incorrect authentication key.")); | ||
} else { | ||
_this.emit('error', new err.RqlDriverError("Server dropped connection with message: \"" + status_str.trim() + "\"")); | ||
_this.emit('error', new err.ReqlDriverError("Server dropped connection with message: \"" + status_str.trim() + "\"")); | ||
return; | ||
@@ -580,3 +586,3 @@ } | ||
wrappedCb = function(error, result) { | ||
var closeCb; | ||
var cleanupSocket, closeCb, _ref; | ||
closeCb = function() { | ||
@@ -589,12 +595,20 @@ if (error != null) { | ||
}; | ||
cleanupSocket = function() { | ||
var _ref; | ||
closeCb(); | ||
if ((_ref = _this.rawSocket) != null) { | ||
_ref.removeAllListeners(); | ||
} | ||
_this.rawSocket = null; | ||
return _this.emit("close"); | ||
}; | ||
if (_this.rawSocket != null) { | ||
_this.rawSocket.once("close", function() { | ||
var _ref; | ||
closeCb(); | ||
if (_this.rawSocket.readyState === 'closed') { | ||
return cleanupSocket(); | ||
} else { | ||
if ((_ref = _this.rawSocket) != null) { | ||
_ref.removeAllListeners(); | ||
_ref.once("close", cleanupSocket); | ||
} | ||
return _this.rawSocket = null; | ||
}); | ||
return _this.rawSocket.end(); | ||
return _this.rawSocket.end(); | ||
} | ||
} else { | ||
@@ -647,3 +661,3 @@ return process.nextTick(closeCb); | ||
if (!HttpConnection.isAvailable()) { | ||
throw new err.RqlDriverError("XMLHttpRequest is not available in this environment"); | ||
throw new err.ReqlDriverError("XMLHttpRequest is not available in this environment"); | ||
} | ||
@@ -664,3 +678,3 @@ HttpConnection.__super__.constructor.call(this, host, callback); | ||
} else { | ||
return _this.emit('error', new err.RqlDriverError("XHR error, http status " + xhr.status + ".")); | ||
return _this.emit('error', new err.ReqlDriverError("XHR error, http status " + xhr.status + ".")); | ||
} | ||
@@ -701,3 +715,3 @@ } | ||
if (!((cb == null) || typeof cb === 'function')) { | ||
throw new err.RqlDriverError("Final argument to `close` must be a callback function or object."); | ||
throw new err.ReqlDriverError("Final argument to `close` must be a callback function or object."); | ||
} | ||
@@ -779,3 +793,3 @@ return HttpConnection.__super__.close.call(this, opts, cb); | ||
} else { | ||
throw new err.RqlDriverError("Neither TCP nor HTTP avaiable in this environment"); | ||
throw new err.ReqlDriverError("Neither TCP nor HTTP avaiable in this environment"); | ||
} | ||
@@ -782,0 +796,0 @@ }; |
{ "name" : "rethinkdb" | ||
, "version" : "2.0.2" | ||
, "version" : "2.1.0" | ||
, "main" : "rethinkdb" | ||
@@ -4,0 +4,0 @@ , "description" : "This package provides the JavaScript driver library for the RethinkDB database server for use either from node or your web-browser." |
@@ -50,2 +50,12 @@ // DO NOT EDIT | ||
ErrorType: { | ||
INTERNAL: 1000000, | ||
RESOURCE_LIMIT: 2000000, | ||
QUERY_LOGIC: 3000000, | ||
NON_EXISTENCE: 3100000, | ||
OP_FAILED: 4100000, | ||
OP_INDETERMINATE: 4200000, | ||
USER: 5000000 | ||
}, | ||
ResponseNote: { | ||
@@ -101,2 +111,5 @@ SEQUENCE_FEED: 1, | ||
MOD: 28, | ||
FLOOR: 183, | ||
CEIL: 184, | ||
ROUND: 185, | ||
APPEND: 29, | ||
@@ -103,0 +116,0 @@ PREPEND: 80, |
53
util.js
// Generated by CoffeeScript 1.7.0 | ||
var convertPseudotype, err, mkAtom, mkErr, mkSeq, plural, recursivelyConvertPseudotype, | ||
var convertPseudotype, err, errorClass, mkAtom, mkErr, mkSeq, plural, protoErrorType, protodef, recursivelyConvertPseudotype, | ||
__slice = [].slice; | ||
@@ -7,2 +7,6 @@ | ||
protodef = require('./proto-def'); | ||
protoErrorType = protodef.Response.ErrorType; | ||
plural = function(number) { | ||
@@ -21,3 +25,3 @@ if (number === 1) { | ||
if (args.length !== fun.length) { | ||
throw new err.RqlDriverError("Expected " + fun.length + " argument" + (plural(fun.length)) + " but found " + args.length + "."); | ||
throw new err.ReqlDriverError("Expected " + fun.length + " argument" + (plural(fun.length)) + " but found " + args.length + "."); | ||
} | ||
@@ -34,8 +38,8 @@ return fun.apply(this, args); | ||
if ((min != null) && (max == null)) { | ||
throw new err.RqlDriverError("Expected " + min + " or more arguments but found " + args.length + "."); | ||
throw new err.ReqlDriverError("Expected " + min + " or more arguments but found " + args.length + "."); | ||
} | ||
if ((max != null) && (min == null)) { | ||
throw new err.RqlDriverError("Expected " + max + " or fewer arguments but found " + args.length + "."); | ||
throw new err.ReqlDriverError("Expected " + max + " or fewer arguments but found " + args.length + "."); | ||
} | ||
throw new err.RqlDriverError("Expected between " + min + " and " + max + " arguments but found " + args.length + "."); | ||
throw new err.ReqlDriverError("Expected between " + min + " and " + max + " arguments but found " + args.length + "."); | ||
} | ||
@@ -58,5 +62,5 @@ return fun.apply(this, args); | ||
if (expectedPosArgs !== 1) { | ||
throw new err.RqlDriverError("Expected " + expectedPosArgs + " arguments (not including options) but found " + numPosArgs + "."); | ||
throw new err.ReqlDriverError("Expected " + expectedPosArgs + " arguments (not including options) but found " + numPosArgs + "."); | ||
} else { | ||
throw new err.RqlDriverError("Expected " + expectedPosArgs + " argument (not including options) but found " + numPosArgs + "."); | ||
throw new err.ReqlDriverError("Expected " + expectedPosArgs + " argument (not including options) but found " + numPosArgs + "."); | ||
} | ||
@@ -102,3 +106,3 @@ } | ||
if (obj['epoch_time'] == null) { | ||
throw new err.RqlDriverError("pseudo-type TIME " + obj + " object missing expected field 'epoch_time'."); | ||
throw new err.ReqlDriverError("pseudo-type TIME " + obj + " object missing expected field 'epoch_time'."); | ||
} | ||
@@ -109,3 +113,3 @@ return new Date(obj['epoch_time'] * 1000); | ||
default: | ||
throw new err.RqlDriverError("Unknown timeFormat run option " + opts.timeFormat + "."); | ||
throw new err.ReqlDriverError("Unknown timeFormat run option " + opts.timeFormat + "."); | ||
} | ||
@@ -131,3 +135,3 @@ break; | ||
default: | ||
throw new err.RqlDriverError("Unknown groupFormat run option " + opts.groupFormat + "."); | ||
throw new err.ReqlDriverError("Unknown groupFormat run option " + opts.groupFormat + "."); | ||
} | ||
@@ -140,3 +144,3 @@ break; | ||
if (obj['data'] == null) { | ||
throw new err.RqlDriverError("pseudo-type BINARY object missing expected field 'data'."); | ||
throw new err.ReqlDriverError("pseudo-type BINARY object missing expected field 'data'."); | ||
} | ||
@@ -147,3 +151,3 @@ return new Buffer(obj['data'], 'base64'); | ||
default: | ||
throw new err.RqlDriverError("Unknown binaryFormat run option " + opts.binaryFormat + "."); | ||
throw new err.ReqlDriverError("Unknown binaryFormat run option " + opts.binaryFormat + "."); | ||
} | ||
@@ -185,2 +189,25 @@ break; | ||
errorClass = (function(_this) { | ||
return function(errorType) { | ||
switch (errorType) { | ||
case protoErrorType.QUERY_LOGIC: | ||
return err.ReqlQueryLogicError; | ||
case protoErrorType.NON_EXISTENCE: | ||
return err.ReqlNonExistenceError; | ||
case protoErrorType.RESOURCE_LIMIT: | ||
return err.ReqlResourceLimitError; | ||
case protoErrorType.USER: | ||
return err.ReqlUserError; | ||
case protoErrorType.INTERNAL: | ||
return err.ReqlInternalError; | ||
case protoErrorType.OP_FAILED: | ||
return err.ReqlOpFailedError; | ||
case protoErrorType.OP_INDETERMINATE: | ||
return err.ReqlOpIndeterminateError; | ||
default: | ||
return err.ReqlRuntimeError; | ||
} | ||
}; | ||
})(this); | ||
module.exports.recursivelyConvertPseudotype = recursivelyConvertPseudotype; | ||
@@ -193,1 +220,3 @@ | ||
module.exports.mkErr = mkErr; | ||
module.exports.errorClass = errorClass; |
Sorry, the diff of this file is too big to display
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
190852
5527
2