Skip to content

Commit

Permalink
removed periods from error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaWise committed May 14, 2017
1 parent b2b2b8a commit 35c1d20
Show file tree
Hide file tree
Showing 32 changed files with 95 additions and 95 deletions.
2 changes: 1 addition & 1 deletion benchmark/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ var getFakeData = (function () {
function getColumn(column) {
if (!this.hasOwnProperty(column)) {
var table = this === largeData ? 'large' : 'small';
throw new TypeError('No data defined for column "' + table + '.' + column + '".');
throw new TypeError('No data defined for column "' + table + '.' + column + '"');
}
return this[column];
}
Expand Down
10 changes: 5 additions & 5 deletions lib/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ var CPPDatabase = require('bindings')({

function Database(filenameGiven, options) {
if (typeof filenameGiven !== 'string') {
throw new TypeError('Expected argument 0 to be a string filename.');
throw new TypeError('Expected argument 0 to be a string filename');
}
var filename = filenameGiven.trim();
if (!filename) {
throw new TypeError('A database filename cannot be an empty string.');
throw new TypeError('A database filename cannot be an empty string');
}
if (/^file:/i.test(filename)) {
throw new TypeError('URI filenames are reserved for internal use only.');
throw new TypeError('URI filenames are reserved for internal use only');
}
if (/^(:memory:)?$/i.test(filename)) {
throw new TypeError('To create an in-memory database, specify a normal filename and use the "memory" option.');
throw new TypeError('To create an in-memory database, specify a normal filename and use the "memory" option');
}

if (typeof options !== 'object' || options === null) {
Expand All @@ -39,7 +39,7 @@ function Database(filenameGiven, options) {
.replace(/#/g, '%23')
+ '?mode=memory&cache=shared';
} else if (!util.pathExists(path.dirname(filename))) {
throw new TypeError('Cannot open database because the directory does not exist.');
throw new TypeError('Cannot open database because the directory does not exist');
}

return new CPPDatabase(filename, filenameGiven, memory, readonly);
Expand Down
18 changes: 9 additions & 9 deletions lib/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ module.exports = function (createFunction) {
options = {};
}
if (typeof func !== 'function') {
throw new TypeError('Expected argument 2 to be a function.');
throw new TypeError('Expected argument 2 to be a function');
}

var name = 'name' in options ? options.name : func.name;
if (typeof name !== 'string') {
throw new TypeError('Expected the "name" option to be a string.');
throw new TypeError('Expected the "name" option to be a string');
}
if (!name) {
throw new TypeError('Cannot create an SQL function without a name.');
throw new TypeError('Cannot create an SQL function without a name');
}

var defaultSafeIntegers = !('safeIntegers' in options);
Expand All @@ -31,28 +31,28 @@ module.exports = function (createFunction) {

if (aggregate) {
if (Object.getPrototypeOf(func) !== GeneratorFunctionProto) {
throw new TypeError('Custom aggregates must be registered as generator functions.');
throw new TypeError('Custom aggregates must be registered as generator functions');
}
var gen = func();
var entry = gen.next();
if (entry.done || typeof entry.value !== 'function') {
throw new TypeError('Custom aggregates must yield a function.');
throw new TypeError('Custom aggregates must yield a function');
}
if (!gen.next().done) {
throw new TypeError('Custom aggregates should only yield once.');
throw new TypeError('Custom aggregates should only yield once');
}
}

if (!varargs) {
argCount = entry ? entry.value.length : func.length;
if (typeof argCount !== 'number') {
throw new TypeError('Expected function.length to be a number.');
throw new TypeError('Expected function.length to be a number');
}
if (argCount % 1 !== 0 || argCount < 0) {
throw new TypeError('Expected function.length to be a positive integer.');
throw new TypeError('Expected function.length to be a positive integer');
}
if (argCount > 127) {
throw new RangeError('Cannot create an SQL function with more than 127 arguments.');
throw new RangeError('Cannot create an SQL function with more than 127 arguments');
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var fs = require('fs');

exports.getBooleanOption = function (options, key) {
if (key in options && typeof options[key] !== 'boolean') {
throw new TypeError('Expected the "' + key + '" option to be a boolean.');
throw new TypeError('Expected the "' + key + '" option to be a boolean');
}
return !!options[key];
};
Expand Down
2 changes: 1 addition & 1 deletion src/binder/bind-args.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ int Binder::BindArgs(Nan::NAN_METHOD_ARGS_TYPE info, int len, Query* query) {
v8::Local<v8::Object> obj = v8::Local<v8::Object>::Cast(arg);
if (IsPlainObject(obj)) {
if (bound_object) {
error = COPY("You cannot specify named parameters in two different objects.");
error = COPY("You cannot specify named parameters in two different objects");
return count;
}
bound_object = true;
Expand Down
2 changes: 1 addition & 1 deletion src/binder/bind-object.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ int Binder::BindObject(v8::Local<v8::Object> obj, BindMap* bindMap) {
return i;
}
if (!has_property.FromJust()) {
CONCAT3(message, "Missing named parameter \"", pairs[i].name, "\".");
CONCAT3(message, "Missing named parameter \"", pairs[i].name, "\"");
error = COPY(message.c_str());
return i;
}
Expand Down
10 changes: 5 additions & 5 deletions src/binder/bind-value.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ void Binder::BindValue(v8::Local<v8::Value> value, int index) {
if (status != SQLITE_OK) {
switch (status) {
case -1:
error = COPY("SQLite3 can only bind numbers, strings, Buffers, and null.");
error = COPY("SQLite3 can only bind numbers, strings, Buffers, and null");
break;
case SQLITE_RANGE:
error = COPY("Too many parameter values were provided.");
error = COPY("Too many parameter values were provided");
break;
case SQLITE_TOOBIG:
error = COPY("The bound string or Buffer is too big.");
error = COPY("The bound string or Buffer is too big");
break;
case SQLITE_NOMEM:
error = COPY("Out of memory.");
error = COPY("Out of memory");
break;
default:
error = COPY("An unexpected error occured while trying to bind parameters.");
error = COPY("An unexpected error occured while trying to bind parameters");
}
}
}
6 changes: 3 additions & 3 deletions src/binder/binder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ void Binder::Bind(Nan::NAN_METHOD_ARGS_TYPE info, int len, Query* query) {
if (!error && count != param_count) {
if (count < param_count) {
if (!(result & 1) && query->GetBindMap()->length) {
error = COPY("Missing named parameters.");
error = COPY("Missing named parameters");
} else {
error = COPY("Too few parameter values were provided.");
error = COPY("Too few parameter values were provided");
}
} else {
error = COPY("Too many parameter values were provided.");
error = COPY("Too many parameter values were provided");
}
}
}
2 changes: 1 addition & 1 deletion src/multi-binder/bind-object.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ int MultiBinder::BindObject(v8::Local<v8::Object> obj, BindMap* bindMap) {
return i;
}
if (!has_property.FromJust()) {
CONCAT3(message, "Missing named parameter \"", pairs[i].name, "\".");
CONCAT3(message, "Missing named parameter \"", pairs[i].name, "\"");
error = COPY(message.c_str());
return i;
}
Expand Down
6 changes: 3 additions & 3 deletions src/multi-binder/multi-binder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ void MultiBinder::Bind(Nan::NAN_METHOD_ARGS_TYPE info, int len, Query* query) {
if (count != param_count_sum) {
if (count < param_count_sum) {
if (!(result & 1) && query->GetBindMap()->length) {
error = COPY("Missing named parameters.");
error = COPY("Missing named parameters");
} else {
error = COPY("Too few parameter values were provided.");
error = COPY("Too few parameter values were provided");
}
} else {
error = COPY("Too many parameter values were provided.");
error = COPY("Too many parameter values were provided");
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/objects/database/checkpoint.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ NAN_METHOD(Database::Checkpoint) {
TRUTHINESS_OF_ARGUMENT(0, force);
Database* db = Nan::ObjectWrap::Unwrap<Database>(info.This());
if (!db->open) {
return Nan::ThrowTypeError("The database connection is not open.");
return Nan::ThrowTypeError("The database connection is not open");
}
if (db->busy) {
return Nan::ThrowTypeError("This database connection is busy executing a query.");
return Nan::ThrowTypeError("This database connection is busy executing a query");
}

int total_frames;
Expand Down
4 changes: 2 additions & 2 deletions src/objects/database/close.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ NAN_METHOD(Database::Close) {

if (db->open) {
if (db->busy) {
return Nan::ThrowTypeError("You cannot close a database while it is executing a query.");
return Nan::ThrowTypeError("You cannot close a database while it is executing a query");
}

db->open = false;
db->CloseChildHandles();
if (db->CloseHandles() != SQLITE_OK) {
return Nan::ThrowError("Failed to successfully close the database connection.");
return Nan::ThrowError("Failed to successfully close the database connection");
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/objects/database/create-function.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ NAN_METHOD(Database::CreateFunction) {

Database* db = Nan::ObjectWrap::Unwrap<Database>(info.This());
if (!db->open) {
return Nan::ThrowTypeError("The database connection is not open.");
return Nan::ThrowTypeError("The database connection is not open");
}
if (db->busy) {
return Nan::ThrowTypeError("This database connection is busy executing a query.");
return Nan::ThrowTypeError("This database connection is busy executing a query");
}

Nan::Utf8String name(nameString);
Expand All @@ -37,7 +37,7 @@ NAN_METHOD(Database::CreateFunction) {

int status = sqlite3_create_function_v2(db->db_handle, *name, argc, mask, new FunctionInfo(db, func, *name, argc, safe_integers), xFunc, xStep, xFinal, FunctionInfo::DestroyFunction);
if (status != SQLITE_OK) {
CONCAT3(message, "Failed to register SQL function (", sqlite3_errmsg(db->db_handle), ").");
CONCAT3(message, "Failed to register SQL function (", sqlite3_errmsg(db->db_handle), ")");
return Nan::ThrowError(message.c_str());
}

Expand Down
12 changes: 6 additions & 6 deletions src/objects/database/create-statement.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ NAN_METHOD(Database::CreateStatement) {

Database* db = Nan::ObjectWrap::Unwrap<Database>(info.This());
if (!db->open) {
return Nan::ThrowTypeError("The database connection is not open.");
return Nan::ThrowTypeError("The database connection is not open");
}
if (db->busy) {
return Nan::ThrowTypeError("This database connection is busy executing a query.");
return Nan::ThrowTypeError("This database connection is busy executing a query");
}

// Construct Statement object.
Expand All @@ -30,21 +30,21 @@ NAN_METHOD(Database::CreateStatement) {

// Validates the newly created statement.
if (status != SQLITE_OK) {
CONCAT3(message, "Failed to construct SQL statement (", sqlite3_errmsg(db->db_handle), ").");
CONCAT3(message, "Failed to construct SQL statement (", sqlite3_errmsg(db->db_handle), ")");
return Nan::ThrowError(message.c_str());
}
if (stmt->st_handle == NULL) {
return Nan::ThrowRangeError("The supplied SQL string contains no statements.");
return Nan::ThrowRangeError("The supplied SQL string contains no statements");
}
if (tail != (const void*)(*utf16 + utf16.length())) {
return Nan::ThrowRangeError("The supplied SQL string contains more than one statement.");
return Nan::ThrowRangeError("The supplied SQL string contains more than one statement");
}

// Determine if the sqlite3_stmt returns data or not.
if (sqlite3_stmt_readonly(stmt->st_handle) && sqlite3_column_count(stmt->st_handle) >= 1) {
stmt->state |= RETURNS_DATA;
} else if (db->readonly) {
return Nan::ThrowTypeError("This operation is not available while in readonly mode.");
return Nan::ThrowTypeError("This operation is not available while in readonly mode");
}
Nan::ForceSet(statement, NEW_INTERNAL_STRING_FAST("source"), source, FROZEN);
Nan::ForceSet(statement, NEW_INTERNAL_STRING_FAST("database"), info.This(), FROZEN);
Expand Down
22 changes: 11 additions & 11 deletions src/objects/database/create-transaction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ NAN_METHOD(Database::CreateTransaction) {

Database* db = Nan::ObjectWrap::Unwrap<Database>(info.This());
if (!db->open) {
return Nan::ThrowTypeError("The database connection is not open.");
return Nan::ThrowTypeError("The database connection is not open");
}
if (db->busy) {
return Nan::ThrowTypeError("This database connection is busy executing a query.");
return Nan::ThrowTypeError("This database connection is busy executing a query");
}
if (db->readonly) {
return Nan::ThrowTypeError("This operation is not available while in readonly mode.");
return Nan::ThrowTypeError("This operation is not available while in readonly mode");
}

unsigned int len = sources->Length();
if (!(len > 0)) {
return Nan::ThrowRangeError("No SQL statements were provided.");
return Nan::ThrowRangeError("No SQL statements were provided");
}
if (len > max_transaction_length) {
return Nan::ThrowRangeError("Too many SQL statements were provided.");
return Nan::ThrowRangeError("Too many SQL statements were provided");
}
v8::Local<v8::Array> digestedSources = Nan::New<v8::Array>(len);

Expand All @@ -32,7 +32,7 @@ NAN_METHOD(Database::CreateTransaction) {
}
v8::Local<v8::Value> value = maybeValue.ToLocalChecked();
if (!value->IsString()) {
return Nan::ThrowTypeError("Expected each item in the given array to be a string.");
return Nan::ThrowTypeError("Expected each item in the given array to be a string");
}
v8::Local<v8::String> source = v8::Local<v8::String>::Cast(value);
v8::String::Value utf16(source);
Expand All @@ -47,7 +47,7 @@ NAN_METHOD(Database::CreateTransaction) {
v8::Local<v8::Value> joinArgs[1] = {Nan::New("\n").ToLocalChecked()};
INVOKE_METHOD(joinedSource, digestedSources, "join", 1, joinArgs)
if (!joinedSource->IsString()) {
return Nan::ThrowTypeError("Expected Array.prototype.join to return a string.");
return Nan::ThrowTypeError("Expected Array.prototype.join to return a string");
}


Expand All @@ -72,17 +72,17 @@ NAN_METHOD(Database::CreateTransaction) {

// Validates the newly created statement.
if (status != SQLITE_OK) {
CONCAT3(message, "Failed to construct SQL statement (", sqlite3_errmsg(db->db_handle), ").");
CONCAT3(message, "Failed to construct SQL statement (", sqlite3_errmsg(db->db_handle), ")");
return Nan::ThrowError(message.c_str());
}
if (trans->handles[i] == NULL) {
return Nan::ThrowTypeError("One of the supplied SQL strings contains no statements.");
return Nan::ThrowTypeError("One of the supplied SQL strings contains no statements");
}
if (tail != (const void*)(*utf16 + utf16.length())) {
return Nan::ThrowRangeError("Each provided string may only contain a single SQL statement.");
return Nan::ThrowRangeError("Each provided string may only contain a single SQL statement");
}
if (sqlite3_stmt_readonly(trans->handles[i])) {
return Nan::ThrowTypeError("Transactions cannot contain read-only statements.");
return Nan::ThrowTypeError("Transactions cannot contain read-only statements");
}
}
Nan::ForceSet(transaction, NEW_INTERNAL_STRING_FAST("source"), joinedSource, FROZEN);
Expand Down
8 changes: 4 additions & 4 deletions src/objects/database/custom-aggregates.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class AggregateInfo {
}
v8::Local<v8::Value> yieldedValue = maybe_yielded_value.ToLocalChecked();
if (state == State::released || !yieldedValue->IsFunction()) {
return ThrowTypeError(ctx, function_info, "Custom aggregate \"", function_info->name, "\" did not yield a function.");
return ThrowTypeError(ctx, function_info, "Custom aggregate \"", function_info->name, "\" did not yield a function");
}
v8::Local<v8::Function> callbackFunction = v8::Local<v8::Function>::Cast(yieldedValue);

Expand All @@ -35,7 +35,7 @@ class AggregateInfo {
}
v8::Local<v8::Value> localLength = maybe_length.ToLocalChecked();
if (!localLength->IsInt32() || argc != v8::Local<v8::Int32>::Cast(localLength)->Value()) {
return ThrowTypeError(ctx, function_info, "Custom aggregate \"", function_info->name, "\" has an inconsistent function.length.");
return ThrowTypeError(ctx, function_info, "Custom aggregate \"", function_info->name, "\" has an inconsistent function.length");
}
}

Expand Down Expand Up @@ -101,7 +101,7 @@ class AggregateInfo {
sqlite3_aggregate_context(ctx, sizeof(AggregateInfo)) \
); \
if (agg_info == NULL) { \
Nan::ThrowError("Out of memory."); \
Nan::ThrowError("Out of memory"); \
function_info->db->was_js_error = true; \
return sqlite3_result_error(ctx, "", 0); \
}
Expand Down Expand Up @@ -133,7 +133,7 @@ void Database::FinishAggregate(sqlite3_context* ctx) {
return;
}
if (agg_info->IsActive()) {
agg_info->ThrowTypeError(ctx, function_info, "Custom aggregate \"", function_info->name, "\" should only yield once.");
agg_info->ThrowTypeError(ctx, function_info, "Custom aggregate \"", function_info->name, "\" should only yield once");
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/objects/database/custom-functions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class FunctionInfo : public Functor { public:
delete[] name;
}
void Invoke(void* ctx) {
CONCAT3(message, "Custom function \"", name, "\" returned an invalid value.");
CONCAT3(message, "Custom function \"", name, "\" returned an invalid value");
Nan::ThrowTypeError(message.c_str());
db->was_js_error = true;
sqlite3_result_error(static_cast<sqlite3_context*>(ctx), "", 0);
Expand Down
Loading

0 comments on commit 35c1d20

Please sign in to comment.