Do not use assert to throw erros as in Node.js > 6 wraps the original error, the keyword 'throw' does the trick and it's backwards compatible

This commit is contained in:
Daniel García Aubert 2018-11-07 18:05:39 +01:00
parent 6984be4edd
commit e0e011e806
5 changed files with 27 additions and 15 deletions

View File

@ -4,7 +4,6 @@
var _ = require('underscore');
var OAuthUtil = require('oauth-client');
var step = require('step');
var assert = require('assert');
var CdbRequest = require('../models/cartodb_request');
var cdbReq = new CdbRequest();
@ -90,7 +89,9 @@ var oAuth = (function(){
return oAuth.parseTokens(req);
},
function getOAuthHash(err, _requestTokens) {
assert.ifError(err);
if (err) {
throw err;
}
// this is oauth request only if oauth headers are present
this.is_oauth_request = !_.isEmpty(_requestTokens);
@ -103,7 +104,9 @@ var oAuth = (function(){
}
},
function regenerateSignature(err, oAuthHash){
assert.ifError(err);
if (err) {
throw err;
}
if (!this.is_oauth_request) {
return null;
}

View File

@ -2,7 +2,6 @@
var _ = require('underscore');
var step = require('step');
var assert = require('assert');
var PSQL = require('cartodb-psql');
var CachedQueryTables = require('../services/cached-query-tables');
const pgEntitiesAccessValidator = require('../services/pg-entities-access-validator');
@ -158,7 +157,9 @@ QueryController.prototype.handleQuery = function (req, res, next) {
});
},
function setHeaders(err, affectedTables) {
assert.ifError(err);
if (err) {
throw err;
}
var mayWrite = queryMayWrite(sql);
if ( req.profiler ) {
@ -206,7 +207,9 @@ QueryController.prototype.handleQuery = function (req, res, next) {
return null;
},
function generateFormat(err){
assert.ifError(err);
if (err) {
throw err;
}
checkAborted('generateFormat');
// TODO: drop this, fix UI!

View File

@ -6,7 +6,6 @@ var fs = require('fs');
var _ = require('underscore');
var PSQL = require('cartodb-psql');
var spawn = require('child_process').spawn;
var assert = require('assert');
// Keeps track of what's waiting baking for export
var bakingExports = {};
@ -95,7 +94,9 @@ OgrFormat.prototype.toOGR = function(options, out_format, out_filename, callback
pg.query(colsql, this);
},
function findSRS(err, result) {
assert.ifError(err);
if (err) {
throw err;
}
var needSRS = that._needSRS;
@ -139,7 +140,9 @@ OgrFormat.prototype.toOGR = function(options, out_format, out_filename, callback
});
},
function spawnDumper(err, srid, type) {
assert.ifError(err);
if (err) {
throw err;
}
var next = this;

View File

@ -3,7 +3,6 @@
var step = require('step');
var fs = require('fs');
var spawn = require('child_process').spawn;
var assert = require('assert');
var ogr = require('./../ogr');
@ -51,12 +50,16 @@ ShpFormat.prototype.toSHP = function (options, callback) {
fs.mkdir(outdirpath, 0o777, this);
},
function spawnDumper(err) {
assert.ifError(err);
if (err) {
throw err;
}
fmtObj.toOGR(options, 'ESRI Shapefile', shapefile, this);
},
function doZip(err) {
assert.ifError(err);
if (err) {
throw err;
}
var next = this;

View File

@ -2,7 +2,6 @@
var step = require('step');
var PSQL = require('cartodb-psql');
var assert = require('assert');
function PostgresFormat(id) {
this.id = id;
@ -82,8 +81,9 @@ PostgresFormat.prototype.handleQueryEnd = function(result) {
that.transform(result, that.opts, this);
},
function sendResults(err, out){
assert.ifError(err);
if (err) {
throw err;
}
// return to browser
if ( out ) {