Respond with 429 and proper message when database fires a timeout error
This commit is contained in:
parent
cff94365ed
commit
fb477260ec
@ -40,12 +40,14 @@ ErrorHandler.prototype.getStatus = function() {
|
||||
statusError = 401;
|
||||
}
|
||||
|
||||
if (message === conditionToMessage[pgErrorCodes.conditionToCode.query_canceled]) {
|
||||
statusError = 429;
|
||||
}
|
||||
|
||||
return statusError;
|
||||
};
|
||||
|
||||
var conditionToMessage = {};
|
||||
conditionToMessage[pgErrorCodes.conditionToCode.query_canceled] = [
|
||||
"Your query was not able to finish.",
|
||||
"Either you have too many queries running or the one you are trying to run is too expensive.",
|
||||
"Try again."
|
||||
'You are over platform\'s limits. Please contact us to know more details'
|
||||
].join(' ');
|
||||
|
@ -782,10 +782,19 @@ it('GET with callback must return 200 status error even if it is an error', func
|
||||
method: 'GET'
|
||||
},
|
||||
{
|
||||
status: 400
|
||||
status: 429,
|
||||
headers: {
|
||||
'Content-Type': 'application/json; charset=utf-8'
|
||||
}
|
||||
},
|
||||
function(err, res) {
|
||||
assert.ok(res.body.match(/was not able to finish.*try again/i));
|
||||
var error = JSON.parse(res.body);
|
||||
assert.deepEqual(error, {
|
||||
error: [
|
||||
'You are over platform\'s limits. Please contact us to know more details'
|
||||
]
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user