method to detect timeout error
This commit is contained in:
parent
d901e81119
commit
df86cc16e4
@ -13,13 +13,7 @@ ErrorHandler.prototype.getName = function() {
|
||||
ErrorHandler.prototype.getMessage = function() {
|
||||
var message = this.err.message;
|
||||
|
||||
// `57014: query_canceled` includes other queries than `statement timeout`, otherwise we could do something more
|
||||
// straightforward like:
|
||||
// return conditionToMessage[this.err.code] || this.err.message;
|
||||
if (message &&
|
||||
(message.match(/statement timeout/) ||
|
||||
message.indexOf('RuntimeError: Execution of function interrupted by signal') > -1)
|
||||
) {
|
||||
if (this.isTimeoutError()) {
|
||||
message = conditionToMessage[pgErrorCodes.conditionToCode.query_canceled];
|
||||
}
|
||||
|
||||
@ -50,6 +44,13 @@ ErrorHandler.prototype.getStatus = function() {
|
||||
return statusError;
|
||||
};
|
||||
|
||||
ErrorHandler.prototype.isTimeoutError = function() {
|
||||
return this.err.message && (
|
||||
this.err.message.match(/statement timeout/) ||
|
||||
this.err.message.indexOf('RuntimeError: Execution of function interrupted by signal') > -1
|
||||
);
|
||||
};
|
||||
|
||||
var conditionToMessage = {};
|
||||
conditionToMessage[pgErrorCodes.conditionToCode.query_canceled] = [
|
||||
'You are over platform\'s limits. Please contact us to know more details'
|
||||
|
Loading…
Reference in New Issue
Block a user