Use BoxError instead of Error in all places

This moves everything other than the addon code and some 'done' logic
This commit is contained in:
Girish Ramakrishnan
2019-12-04 10:29:06 -08:00
parent 3623831390
commit 30eccfb54b
17 changed files with 45 additions and 36 deletions

View File

@@ -14,6 +14,7 @@ exports = module.exports = {
var assert = require('assert'),
async = require('async'),
BoxError = require('./boxerror.js'),
child_process = require('child_process'),
constants = require('./constants.js'),
mysql = require('mysql'),
@@ -112,7 +113,7 @@ function clear(callback) {
function beginTransaction(callback) {
assert.strictEqual(typeof callback, 'function');
if (gConnectionPool === null) return callback(new Error('No database connection pool.'));
if (gConnectionPool === null) return callback(new BoxError(BoxError.DATABASE_ERROR, 'No database connection pool.'));
gConnectionPool.getConnection(function (error, connection) {
if (error) {
@@ -156,7 +157,7 @@ function query() {
var callback = args[args.length - 1];
assert.strictEqual(typeof callback, 'function');
if (gDefaultConnection === null) return callback(new Error('No connection to database'));
if (gDefaultConnection === null) return callback(new BoxError(BoxError.DATABASE_ERROR, 'No connection to database'));
args[args.length -1 ] = function (error, result) {
if (error && error.fatal) {