update render limits error message
This commit is contained in:
@@ -46,30 +46,39 @@ function isDatasourceTimeoutError (err) {
|
||||
return err.message && err.message.match(/canceling statement due to statement timeout/i);
|
||||
}
|
||||
|
||||
function isTimeoutError (err) {
|
||||
return isRenderTimeoutError(err) || isDatasourceTimeoutError(err);
|
||||
function isTimeoutError (errorTypes) {
|
||||
return errorTypes.renderTimeoutError || errorTypes.datasourceTimeoutError;
|
||||
}
|
||||
|
||||
function getErrorTypes(error) {
|
||||
return {
|
||||
renderTimeoutError: isRenderTimeoutError(error),
|
||||
datasourceTimeoutError: isDatasourceTimeoutError(error),
|
||||
};
|
||||
}
|
||||
|
||||
function populateTimeoutErrors (errors) {
|
||||
return errors.map(function (error) {
|
||||
if (isRenderTimeoutError(error)) {
|
||||
error.subtype = 'render';
|
||||
}
|
||||
const errorTypes = getErrorTypes(error);
|
||||
|
||||
const IS_DATASOURCE_TIMEOUT_ERROR = isDatasourceTimeoutError(error);
|
||||
|
||||
if (isTimeoutError(error)) {
|
||||
if (isTimeoutError(errorTypes)) {
|
||||
error.message = 'You are over platform\'s limits. Please contact us to know more details';
|
||||
error.type = 'limit';
|
||||
error.http_status = 429;
|
||||
}
|
||||
|
||||
if (IS_DATASOURCE_TIMEOUT_ERROR) {
|
||||
if (errorTypes.datasourceTimeoutError) {
|
||||
error.subtype = 'datasource';
|
||||
error.message = 'You are over platform\'s limits: SQL query timeout error.' +
|
||||
' Refactor your query before running again or contact CARTO support for more details.';
|
||||
}
|
||||
|
||||
if (errorTypes.renderTimeoutError) {
|
||||
error.subtype = 'render';
|
||||
error.message = 'You are over platform\'s limits: Render timeout error.' +
|
||||
' Contact CARTO support for more details.';
|
||||
}
|
||||
|
||||
return error;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ const DATASOURCE_TIMEOUT_ERROR = {
|
||||
}]
|
||||
};
|
||||
|
||||
describe.only('user database timeout limit', function () {
|
||||
describe('user database timeout limit', function () {
|
||||
describe('dataview', function () {
|
||||
beforeEach(function (done) {
|
||||
const mapconfig = createMapConfig();
|
||||
|
||||
@@ -23,6 +23,9 @@ const validationPointSleepSql = `
|
||||
2 val
|
||||
`;
|
||||
|
||||
const renderTimeoutErrorMessage = 'You are over platform\'s limits: Render timeout error.' +
|
||||
' Contact CARTO support for more details.';
|
||||
|
||||
const createMapConfig = ({
|
||||
version = '1.6.0',
|
||||
type = 'cartodb',
|
||||
@@ -96,11 +99,11 @@ describe('user render timeout limit', function () {
|
||||
assert.ifError(err);
|
||||
|
||||
assert.deepEqual(timeoutError, {
|
||||
errors: ["You are over platform\'s limits. Please contact us to know more details"],
|
||||
errors: [renderTimeoutErrorMessage],
|
||||
errors_with_context: [{
|
||||
type: 'limit',
|
||||
subtype: 'render',
|
||||
message: "You are over platform\'s limits. Please contact us to know more details",
|
||||
message: renderTimeoutErrorMessage,
|
||||
layer: {
|
||||
id: "layer0",
|
||||
index: 0,
|
||||
@@ -188,11 +191,11 @@ describe('user render timeout limit', function () {
|
||||
assert.ifError(err);
|
||||
|
||||
assert.deepEqual(timeoutError, {
|
||||
errors: ["You are over platform\'s limits. Please contact us to know more details"],
|
||||
errors: [renderTimeoutErrorMessage],
|
||||
errors_with_context: [{
|
||||
type: 'limit',
|
||||
subtype: 'render',
|
||||
message: "You are over platform\'s limits. Please contact us to know more details"
|
||||
message: renderTimeoutErrorMessage
|
||||
}]
|
||||
});
|
||||
|
||||
@@ -282,11 +285,11 @@ describe('user render timeout limit', function () {
|
||||
assert.ifError(err);
|
||||
|
||||
assert.deepEqual(tile, {
|
||||
errors: ['You are over platform\'s limits. Please contact us to know more details'],
|
||||
errors: [renderTimeoutErrorMessage],
|
||||
errors_with_context: [{
|
||||
type: 'limit',
|
||||
subtype: 'render',
|
||||
message: 'You are over platform\'s limits. Please contact us to know more details'
|
||||
message: renderTimeoutErrorMessage
|
||||
}]
|
||||
});
|
||||
|
||||
@@ -384,11 +387,11 @@ describe('user render timeout limit', function () {
|
||||
assert.ifError(err);
|
||||
|
||||
assert.deepEqual(timeoutError, {
|
||||
errors: ["You are over platform\'s limits. Please contact us to know more details"],
|
||||
errors: [renderTimeoutErrorMessage],
|
||||
errors_with_context: [{
|
||||
type: 'limit',
|
||||
subtype: 'render',
|
||||
message: "You are over platform\'s limits. Please contact us to know more details"
|
||||
message: renderTimeoutErrorMessage
|
||||
}]
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user