Updates to consider the case when there are not enough funds
This commit is contained in:
1 parent
6ca5036540
commit
31a22bec3f
2 files changed
+49
-13
No files matched your search
@@ -30,9 +30,9 @@
|
||||
let stringExchangeResponse = JSON.stringify(exchangeResponse);
|
||||
let stringExchangeErr = JSON.stringify(exchangeErr);
|
||||
|
||||
if (INFO_LOG === true) { logger.write( MODULE_NAME, "[INFO] analizeResponse -> stringExchangeErr = " + stringExchangeErr); }
|
||||
if (LOG_FILE_CONTENT === true) { logger.write( MODULE_NAME, "[INFO] analizeResponse -> exchangeResponse = " + stringExchangeResponse); }
|
||||
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] analizeResponse -> exchangeErr = " + stringExchangeErr); }
|
||||
if (LOG_FILE_CONTENT === true) { logger.write(MODULE_NAME, "[INFO] analizeResponse -> exchangeResponse = " + stringExchangeResponse); }
|
||||
|
||||
if (stringExchangeErr.indexOf("ETIMEDOUT") > 0 ||
|
||||
stringExchangeErr.indexOf("ENOTFOUND") > 0 ||
|
||||
stringExchangeErr.indexOf("ECONNREFUSED") > 0 ||
|
||||
@@ -44,39 +44,58 @@
|
||||
stringExchangeResponse.indexOf("Bad gateway") > 0 ||
|
||||
stringExchangeResponse.indexOf("Internal error. Please try again") > 0))) {
|
||||
|
||||
logger.write( MODULE_NAME, "[WARN] analizeResponse -> Timeout reached or connection problem while trying to access the Exchange API. Requesting new execution later.");
|
||||
logger.write(MODULE_NAME, "[WARN] analizeResponse -> Timeout reached or connection problem while trying to access the Exchange API. Requesting new execution later.");
|
||||
logger.write(MODULE_NAME, "[WARN] analizeResponse -> stringExchangeErr = " + stringExchangeErr);
|
||||
|
||||
notOkCallBack(window.DEFAULT_RETRY_RESPONSE);
|
||||
return;
|
||||
|
||||
} else {
|
||||
|
||||
if (exchangeResponse !== null && exchangeResponse !== undefined) {
|
||||
if (JSON.stringify(exchangeResponse).indexOf("error") > 0) {
|
||||
|
||||
if (JSON.stringify(exchangeResponse).indexOf("error") > 0) {
|
||||
logger.write(MODULE_NAME, "[ERROR] analizeResponse -> Unexpected response from the Exchange.");
|
||||
logger.write(MODULE_NAME, "[ERROR] analizeResponse -> JSON.stringify(exchangeErr) = " + JSON.stringify(exchangeErr));
|
||||
logger.write(MODULE_NAME, "[ERROR] analizeResponse -> exchangeErr = " + exchangeErr);
|
||||
logger.write(MODULE_NAME, "[ERROR] analizeResponse -> exchangeResponse = " + exchangeResponse);
|
||||
|
||||
/* {"error":"Not enough USDT.","success":0}*/
|
||||
|
||||
if (JSON.stringify(exchangeResponse).indexOf("Not enough") > 0) {
|
||||
|
||||
let err = {
|
||||
resutl: window.CUSTOM_FAIL_RESPONSE.result,
|
||||
message: exchangeResponse.error
|
||||
};
|
||||
|
||||
notOkCallBack(err);
|
||||
|
||||
} else {
|
||||
|
||||
logger.write( MODULE_NAME, "[ERROR] analizeResponse -> Unexpected response from the Exchange.");
|
||||
logger.write(MODULE_NAME, "[ERROR] analizeResponse -> exchangeResponse = " + JSON.stringify(exchangeResponse));
|
||||
notOkCallBack(window.DEFAULT_FAIL_RESPONSE);
|
||||
return;
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (exchangeErr) {
|
||||
|
||||
logger.write( MODULE_NAME, "[ERROR] analizeResponse -> Unexpected error trying to contact the Exchange.");
|
||||
logger.write(MODULE_NAME, "[ERROR] analizeResponse -> Unexpected error trying to contact the Exchange.");
|
||||
logger.write(MODULE_NAME, "[ERROR] analizeResponse -> exchangeErr = " + exchangeErr);
|
||||
|
||||
notOkCallBack(window.DEFAULT_FAIL_RESPONSE);
|
||||
return;
|
||||
|
||||
} else {
|
||||
|
||||
logger.write( MODULE_NAME, "[INFO] analizeResponse -> No problem found.");
|
||||
logger.write(MODULE_NAME, "[INFO] analizeResponse -> No problem found.");
|
||||
okCallBack();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
logger.write( MODULE_NAME, "[ERROR] analizeResponse -> err.message = " + err.message);
|
||||
logger.write(MODULE_NAME, "[ERROR] analizeResponse -> err.message = " + err.message);
|
||||
notOkCallBack(window.DEFAULT_FAIL_RESPONSE);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -437,9 +437,26 @@
|
||||
if (JSON.stringify(exchangeResponse).indexOf("error") > 0) {
|
||||
|
||||
logger.write(MODULE_NAME, "[ERROR] analizeResponse -> Unexpected response from the Exchange.");
|
||||
logger.write(MODULE_NAME, "[ERROR] analizeResponse -> JSON.stringify(exchangeErr) = " + JSON.stringify(exchangeErr));
|
||||
logger.write(MODULE_NAME, "[ERROR] analizeResponse -> exchangeErr = " + exchangeErr);
|
||||
logger.write(MODULE_NAME, "[ERROR] analizeResponse -> exchangeResponse = " + exchangeResponse);
|
||||
|
||||
notOkCallBack(global.DEFAULT_FAIL_RESPONSE);
|
||||
/* {"error":"Not enough USDT.","success":0}*/
|
||||
|
||||
if (JSON.stringify(exchangeResponse).indexOf("Not enough") > 0) {
|
||||
|
||||
let err = {
|
||||
resutl: global.CUSTOM_FAIL_RESPONSE.result,
|
||||
message: exchangeResponse.error
|
||||
};
|
||||
|
||||
notOkCallBack(err);
|
||||
|
||||
} else {
|
||||
|
||||
notOkCallBack(global.DEFAULT_FAIL_RESPONSE);
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user