diff --git a/workers/loc.api/errors/index.js b/workers/loc.api/errors/index.js index 07abb655..0a42b738 100644 --- a/workers/loc.api/errors/index.js +++ b/workers/loc.api/errors/index.js @@ -71,8 +71,8 @@ class ObjectMappingError extends BaseError { } class CurrencyConversionDataFindingError extends BaseError { - constructor (message = 'ERR_DATA_IS_NOT_FOUND_TO_CONVERT_CURRENCY') { - super(message) + constructor (data, message = 'ERR_DATA_IS_NOT_FOUND_TO_CONVERT_CURRENCY') { + super({ data, message }) } } diff --git a/workers/loc.api/sync/currency.converter/index.js b/workers/loc.api/sync/currency.converter/index.js index 0ae43616..3c671e1f 100644 --- a/workers/loc.api/sync/currency.converter/index.js +++ b/workers/loc.api/sync/currency.converter/index.js @@ -348,17 +348,25 @@ class CurrencyConverter { if (typeof symbol !== 'string') { return '' } - if (symbol.length < 8) { + if (symbol.length < 6) { return symbol } + + const hasFlag = ( + symbol.startsWith('t') || + symbol.startsWith('f') + ) + const flag = hasFlag + ? symbol[0] + : 't' + if ( - symbol[0] !== 't' && - symbol[0] !== 'f' + symbol.length === 7 && + hasFlag ) { return symbol } - const flag = symbol[0] const [firstSymb, lastSymb] = splitSymbolPairs(symbol) const _firstSymb = this._getConvertingSymb(firstSymb) const _lastSymb = this._getConvertingSymb(lastSymb) @@ -1031,7 +1039,9 @@ class CurrencyConverter { ) if (!Number.isFinite(price)) { - throw new CurrencyConversionDataFindingError() + throw new CurrencyConversionDataFindingError( + { symbol: reqSymb, mts } + ) } return price @@ -1082,7 +1092,9 @@ class CurrencyConverter { ) } - throw new CurrencyConversionDataFindingError() + throw new CurrencyConversionDataFindingError( + { symbol: reqSymb, mts: end } + ) } async convertManyByCandles (data, convSchema) {