Merge pull request #519 from CartoDB/fix-error-with-context
Now errors with context have the same schema.
This commit is contained in:
commit
256032ca4a
@ -61,15 +61,15 @@ AnalysisMapConfigAdapter.prototype.getMapConfig = function(user, requestMapConfi
|
||||
function createAnalysis(analysisDefinition, index, done) {
|
||||
self.analysisBackend.create(analysisConfiguration, analysisDefinition, function (err, analysis) {
|
||||
if (err) {
|
||||
err.context = {
|
||||
type: 'analysis',
|
||||
analysis: {
|
||||
index: index,
|
||||
id: analysisDefinition.id,
|
||||
type: analysisDefinition.type
|
||||
}
|
||||
var error = new Error(err.message);
|
||||
error.type = 'analysis';
|
||||
error.context = {};
|
||||
error.context.layer = {
|
||||
index: index,
|
||||
id: analysisDefinition.id,
|
||||
type: analysisDefinition.type
|
||||
};
|
||||
return done(err);
|
||||
return done(error);
|
||||
}
|
||||
|
||||
done(null, analysis);
|
||||
@ -295,4 +295,4 @@ function AnalysisError(message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
require('util').inherits(AnalysisError, Error);
|
||||
require('util').inherits(AnalysisError, Error);
|
||||
|
@ -199,10 +199,14 @@ describe('analysis-layers error cases', function() {
|
||||
'Analysis requires authentication with API key: permission denied.'
|
||||
);
|
||||
|
||||
assert.equal(layergroupResult.errors_with_context[0].context.type, 'analysis');
|
||||
assert.equal(layergroupResult.errors_with_context[0].context.analysis.index, 0);
|
||||
assert.equal(layergroupResult.errors_with_context[0].context.analysis.id, 'HEAD');
|
||||
assert.equal(layergroupResult.errors_with_context[0].context.analysis.type, 'buffer');
|
||||
assert.equal(layergroupResult.errors_with_context[0].type, 'analysis');
|
||||
assert.equal(
|
||||
layergroupResult.errors_with_context[0].message,
|
||||
'Analysis requires authentication with API key: permission denied.'
|
||||
);
|
||||
assert.equal(layergroupResult.errors_with_context[0].context.layer.index, 0);
|
||||
assert.equal(layergroupResult.errors_with_context[0].context.layer.id, 'HEAD');
|
||||
assert.equal(layergroupResult.errors_with_context[0].context.layer.type, 'buffer');
|
||||
|
||||
testClient.drain(done);
|
||||
});
|
||||
@ -252,10 +256,11 @@ describe('analysis-layers error cases', function() {
|
||||
'Missing required param "radius"'
|
||||
);
|
||||
|
||||
assert.equal(layergroupResult.errors_with_context[0].context.type, 'analysis');
|
||||
assert.equal(layergroupResult.errors_with_context[0].context.analysis.index, 0);
|
||||
assert.equal(layergroupResult.errors_with_context[0].context.analysis.id, 'HEAD');
|
||||
assert.equal(layergroupResult.errors_with_context[0].context.analysis.type, 'buffer');
|
||||
assert.equal(layergroupResult.errors_with_context[0].type, 'analysis');
|
||||
assert.equal(layergroupResult.errors_with_context[0].message, 'Missing required param "radius"');
|
||||
assert.equal(layergroupResult.errors_with_context[0].context.layer.index, 0);
|
||||
assert.equal(layergroupResult.errors_with_context[0].context.layer.id, 'HEAD');
|
||||
assert.equal(layergroupResult.errors_with_context[0].context.layer.type, 'buffer');
|
||||
|
||||
testClient.drain(done);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user