More clear turbo-carto error messages: no context in message

This commit is contained in:
Raul Ochoa 2016-07-06 12:34:09 +02:00
parent f55b748d20
commit 80d5b29902
3 changed files with 10 additions and 11 deletions

View File

@ -5,6 +5,7 @@
Released 2016-mm-dd
Enhancements:
- More clear turbo-carto error messages: no context in message.
- Return multiple turbo-carto errors #541.
Announcements:

View File

@ -87,7 +87,7 @@ TurboCartoAdapter.prototype._parseCartoCss = function (username, params, layer,
function processCallback(err, cartocss) {
// Only return turbo-carto errors
if (err && err.name === 'TurboCartoError') {
var error = new Error('turbo-carto: ' + err.message);
var error = new Error(err.message);
error.http_status = 400;
error.type = 'layer';
error.subtype = 'turbo-carto';
@ -115,9 +115,7 @@ TurboCartoAdapter.prototype._parseCartoCss = function (username, params, layer,
var tokensQuery = tokensQueryTpl({_sql: layerRawSql});
return pg.query(tokensQuery, function(err, resultSet) {
if (err) {
var error = new Error('turbo-carto: ' + err.message);
error.type = 'turbo-carto';
return processCallback(error);
return processCallback(err);
}
resultSet = resultSet || {};

View File

@ -56,7 +56,7 @@ describe('turbo-carto error cases', function() {
assert.ok(layergroup.hasOwnProperty('errors'));
assert.equal(layergroup.errors.length, 1);
assert.ok(layergroup.errors[0].match(/^turbo-carto/));
assert.ok(layergroup.errors[0].match(/^Failed\sto\sprocess/));
assert.ok(layergroup.errors[0].match(/invalid\sramp\slength/i));
done();
@ -70,7 +70,7 @@ describe('turbo-carto error cases', function() {
assert.ok(layergroup.hasOwnProperty('errors'));
assert.equal(layergroup.errors.length, 1);
assert.ok(layergroup.errors[0].match(/^turbo-carto/));
assert.ok(layergroup.errors[0].match(/^Failed\sto\sprocess/));
assert.ok(layergroup.errors[0].match(/unable\sto\scompute\sramp/i));
assert.ok(layergroup.errors[0].match(/wadus_column/));
@ -85,7 +85,7 @@ describe('turbo-carto error cases', function() {
assert.ok(layergroup.hasOwnProperty('errors'));
assert.equal(layergroup.errors.length, 1);
assert.ok(layergroup.errors[0].match(/^turbo-carto/));
assert.ok(layergroup.errors[0].match(/^Failed\sto\sprocess/));
assert.ok(layergroup.errors[0].match(/unable\sto\scompute\sramp/i));
assert.ok(layergroup.errors[0].match(/invalid\smethod\s\"wadusmethod\"/i));
@ -100,7 +100,7 @@ describe('turbo-carto error cases', function() {
assert.ok(layergroup.hasOwnProperty('errors'));
assert.equal(layergroup.errors.length, 1);
assert.ok(!layergroup.errors[0].match(/^turbo-carto/));
assert.ok(!layergroup.errors[0].match(/^Failed\sto\sprocess/));
assert.ok(layergroup.errors[0].match(/invalid\scode/i));
done();
@ -116,7 +116,7 @@ describe('turbo-carto error cases', function() {
assert.equal(layergroup.errors_with_context.length, 1);
assert.equal(layergroup.errors_with_context[0].type, 'layer');
assert.equal(layergroup.errors_with_context[0].subtype, 'turbo-carto');
assert.ok(layergroup.errors_with_context[0].message.match(/^turbo-carto/));
assert.ok(layergroup.errors_with_context[0].message.match(/^Failed\sto\sprocess/));
assert.ok(layergroup.errors_with_context[0].message.match(/unable\sto\scompute\sramp/i));
assert.ok(layergroup.errors_with_context[0].message.match(/wadus_column/));
@ -172,14 +172,14 @@ describe('turbo-carto error cases', function() {
assert.equal(layergroup.errors_with_context[0].type, 'layer');
assert.equal(layergroup.errors_with_context[0].subtype, 'turbo-carto');
assert.ok(layergroup.errors_with_context[0].message.match(/^turbo-carto/));
assert.ok(layergroup.errors_with_context[0].message.match(/^Failed\sto\sprocess/));
assert.ok(layergroup.errors_with_context[0].message.match(/unable\sto\scompute\sramp/i));
assert.ok(layergroup.errors_with_context[0].message.match(/wadus_column/));
assert.equal(layergroup.errors_with_context[0].layer.id, 'layer0');
assert.equal(layergroup.errors_with_context[1].type, 'layer');
assert.equal(layergroup.errors_with_context[1].subtype, 'turbo-carto');
assert.ok(layergroup.errors_with_context[1].message.match(/^turbo-carto/));
assert.ok(layergroup.errors_with_context[1].message.match(/^Failed\sto\sprocess/));
assert.ok(layergroup.errors_with_context[1].message.match(/unable\sto\scompute\sramp/i));
assert.ok(layergroup.errors_with_context[1].message.match(/invalid_column/));
assert.equal(layergroup.errors_with_context[1].layer.id, 'layer1');