Improve timeout error message
This commit is contained in:
parent
1fdc0621e7
commit
44fc34b1ce
@ -196,7 +196,7 @@ BaseController.prototype.send = function(req, res, body, status, headers) {
|
||||
BaseController.prototype.sendError = function(req, res, err, label) {
|
||||
var allErrors = Array.isArray(err) ? err : [err];
|
||||
|
||||
allErrors = populateTimeoutErrors(allErrors)
|
||||
allErrors = populateTimeoutErrors(allErrors);
|
||||
|
||||
label = label || 'UNKNOWN';
|
||||
err = allErrors[0] || new Error(label);
|
||||
@ -304,22 +304,16 @@ function statusFromErrorMessage(errMsg) {
|
||||
statusCode = 404;
|
||||
}
|
||||
}
|
||||
else if ( -1 !== errMsg.indexOf('Render timed out') ) {
|
||||
statusCode = 429; // under discussion
|
||||
}
|
||||
else if ( -1 !== errMsg.indexOf('canceling statement due to statement timeout') ) {
|
||||
statusCode = 429; // under discussion
|
||||
}
|
||||
|
||||
return statusCode;
|
||||
}
|
||||
|
||||
function isRenderTimeoutError (err) {
|
||||
return err.message && (-1 !== err.message.indexOf('Render timed out'))
|
||||
return err.message && (-1 !== err.message.indexOf('Render timed out'));
|
||||
}
|
||||
|
||||
function isDatasourceTimeoutError (err) {
|
||||
return err.message && (-1 !== err.message.indexOf('canceling statement due to statement timeout'))
|
||||
return err.message && (-1 !== err.message.indexOf('canceling statement due to statement timeout'));
|
||||
}
|
||||
|
||||
function isTimeoutError (err) {
|
||||
@ -328,19 +322,20 @@ function isTimeoutError (err) {
|
||||
|
||||
function populateTimeoutErrors (errors) {
|
||||
return errors.map(function (error) {
|
||||
if (isTimeoutError(error)) {
|
||||
error.type = 'limit'
|
||||
}
|
||||
|
||||
if (isRenderTimeoutError(error)) {
|
||||
error.subtype = 'render'
|
||||
error.subtype = 'render';
|
||||
}
|
||||
|
||||
if (isDatasourceTimeoutError(error)) {
|
||||
error.subtype = 'datasource';
|
||||
}
|
||||
|
||||
error.subtype = 'datasource'
|
||||
if (isTimeoutError(error)) {
|
||||
error.message = 'You are over platform limits. Please contact us to know more details';
|
||||
error.type = 'limit';
|
||||
error.http_status = 429;
|
||||
}
|
||||
|
||||
return error;
|
||||
})
|
||||
});
|
||||
}
|
||||
|
@ -102,11 +102,13 @@ describe('render limits', function() {
|
||||
assert.response(server,
|
||||
createRequest(layergroup, user),
|
||||
{
|
||||
status: 400
|
||||
status: 429
|
||||
},
|
||||
function(res) {
|
||||
var parsed = JSON.parse(res.body);
|
||||
assert.deepEqual(parsed.errors, [ 'Render timed out' ]);
|
||||
assert.deepEqual(parsed.errors, [
|
||||
'You are over platform limits. Please contact us to know more details'
|
||||
]);
|
||||
done();
|
||||
}
|
||||
);
|
||||
@ -167,11 +169,13 @@ describe('render limits', function() {
|
||||
encoding: 'binary'
|
||||
},
|
||||
{
|
||||
status: 400
|
||||
status: 429
|
||||
},
|
||||
function(res) {
|
||||
var parsed = JSON.parse(res.body);
|
||||
assert.deepEqual(parsed.errors, ['Render timed out']);
|
||||
assert.deepEqual(parsed.errors, [
|
||||
'You are over platform limits. Please contact us to know more details'
|
||||
]);
|
||||
done();
|
||||
}
|
||||
);
|
||||
|
@ -86,11 +86,11 @@ describe('user database timeout limit', function () {
|
||||
assert.ifError(err);
|
||||
|
||||
assert.deepEqual(dataview, {
|
||||
errors: ['canceling statement due to statement timeout'],
|
||||
errors: ['You are over platform limits. Please contact us to know more details'],
|
||||
errors_with_context: [{
|
||||
type: 'limit',
|
||||
subtype: 'datasource',
|
||||
message: 'canceling statement due to statement timeout'
|
||||
message: 'You are over platform limits. Please contact us to know more details'
|
||||
}]
|
||||
});
|
||||
|
||||
@ -129,11 +129,11 @@ describe('user database timeout limit', function () {
|
||||
|
||||
this.testClient.getLayergroup(expectedResponse, (err, timeoutError) => {
|
||||
assert.deepEqual(timeoutError, {
|
||||
errors: [ 'TorqueRenderer: canceling statement due to statement timeout' ],
|
||||
errors: [ 'You are over platform limits. Please contact us to know more details' ],
|
||||
errors_with_context: [{
|
||||
type: 'limit',
|
||||
subtype: 'datasource',
|
||||
message: 'TorqueRenderer: canceling statement due to statement timeout',
|
||||
message: 'You are over platform limits. Please contact us to know more details',
|
||||
layer: { id: 'torque-layer0', index: 0, type: 'torque' }
|
||||
}]
|
||||
});
|
||||
@ -198,11 +198,11 @@ describe('user database timeout limit', function () {
|
||||
assert.ifError(err);
|
||||
|
||||
assert.deepEqual(attributes, {
|
||||
errors: [ 'TorqueRenderer: canceling statement due to statement timeout' ],
|
||||
errors: [ 'You are over platform limits. Please contact us to know more details' ],
|
||||
errors_with_context: [{
|
||||
type: 'limit',
|
||||
subtype: 'datasource',
|
||||
message: 'TorqueRenderer: canceling statement due to statement timeout',
|
||||
message: 'You are over platform limits. Please contact us to know more details',
|
||||
}]
|
||||
});
|
||||
|
||||
@ -245,11 +245,11 @@ describe('user database timeout limit', function () {
|
||||
|
||||
this.testClient.getLayergroup(expectedResponse, (err, timeoutError) => {
|
||||
assert.deepEqual(timeoutError, {
|
||||
errors: [ 'canceling statement due to statement timeout' ],
|
||||
errors: [ 'You are over platform limits. Please contact us to know more details' ],
|
||||
errors_with_context: [{
|
||||
type: 'limit',
|
||||
subtype: 'datasource',
|
||||
message: 'canceling statement due to statement timeout',
|
||||
message: 'You are over platform limits. Please contact us to know more details',
|
||||
layer: {
|
||||
id: 'layer0',
|
||||
index: 0,
|
||||
@ -322,11 +322,11 @@ describe('user database timeout limit', function () {
|
||||
assert.ifError(err);
|
||||
|
||||
assert.deepEqual(attributes, {
|
||||
errors: ['canceling statement due to statement timeout'],
|
||||
errors: ['You are over platform limits. Please contact us to know more details'],
|
||||
errors_with_context: [{
|
||||
type: 'limit',
|
||||
subtype: 'datasource',
|
||||
message: 'canceling statement due to statement timeout'
|
||||
message: 'You are over platform limits. Please contact us to know more details'
|
||||
}]
|
||||
});
|
||||
|
||||
|
@ -95,11 +95,11 @@ describe('user render timeout limit', function () {
|
||||
assert.ifError(err);
|
||||
|
||||
assert.deepEqual(timeoutError, {
|
||||
errors: ["Render timed out"],
|
||||
errors: ["You are over platform limits. Please contact us to know more details"],
|
||||
errors_with_context: [{
|
||||
type: 'limit',
|
||||
subtype: 'render',
|
||||
message: "Render timed out",
|
||||
message: "You are over platform limits. Please contact us to know more details",
|
||||
layer: {
|
||||
id: "layer0",
|
||||
index: 0,
|
||||
@ -186,11 +186,11 @@ describe('user render timeout limit', function () {
|
||||
assert.ifError(err);
|
||||
|
||||
assert.deepEqual(timeoutError, {
|
||||
errors: ["Render timed out"],
|
||||
errors: ["You are over platform limits. Please contact us to know more details"],
|
||||
errors_with_context: [{
|
||||
type: 'limit',
|
||||
subtype: 'render',
|
||||
message: "Render timed out"
|
||||
message: "You are over platform limits. Please contact us to know more details"
|
||||
}]
|
||||
});
|
||||
|
||||
@ -231,11 +231,11 @@ describe('user render timeout limit', function () {
|
||||
assert.ifError(err);
|
||||
|
||||
assert.deepEqual(tile, {
|
||||
errors: ['Render timed out'],
|
||||
errors: ['You are over platform limits. Please contact us to know more details'],
|
||||
errors_with_context: [{
|
||||
type: 'limit',
|
||||
subtype: 'render',
|
||||
message: 'Render timed out'
|
||||
message: 'You are over platform limits. Please contact us to know more details'
|
||||
}]
|
||||
});
|
||||
|
||||
@ -276,11 +276,11 @@ describe('user render timeout limit', function () {
|
||||
assert.ifError(err);
|
||||
|
||||
assert.deepEqual(tile, {
|
||||
errors: ['Render timed out'],
|
||||
errors: ['You are over platform limits. Please contact us to know more details'],
|
||||
errors_with_context: [{
|
||||
type: 'limit',
|
||||
subtype: 'render',
|
||||
message: 'Render timed out'
|
||||
message: 'You are over platform limits. Please contact us to know more details'
|
||||
}]
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user