diff --git a/core/package.json b/core/package.json index 5deba3d90..cb27c4b08 100644 --- a/core/package.json +++ b/core/package.json @@ -63,7 +63,7 @@ "adapter-hash": "node --no-warnings --import=specifier-resolution-node/register --experimental-json-modules dist/cli/generate-adapter-hash.js", "aggregator-hash": "node --no-warnings --import=specifier-resolution-node/register --experimental-json-modules dist/cli/generate-aggregator-hash.js", "flush": "node --no-warnings --import=specifier-resolution-node/register --experimental-json-modules dist/tools/flush-queues.js", - "test": "node --no-warnings --experimental-vm-modules node_modules/jest/bin/jest.js", + "test": "node --no-warnings --experimental-vm-modules node_modules/.bin/jest", "lint": "DEBUG=eslint:cli-engine eslint 'src/**/*.ts' 'src/*.ts' 'test/*.ts'", "bull-dashboard": "docker-compose -f docker-compose.bull-monitor.yaml up" }, diff --git a/core/src/api.ts b/core/src/api.ts index 18afb3d3f..c0060a3f8 100644 --- a/core/src/api.ts +++ b/core/src/api.ts @@ -69,7 +69,11 @@ export async function getReporters({ return (await axios.get(endpoint, { data: { service, chain } }))?.data } catch (e) { logger?.error({ name: 'getReporters', file: FILE_NAME, ...e }, 'error') - throw new OraklError(OraklErrorCode.GetReporterRequestFailed) + if (e.code === 'ECONNREFUSED') { + throw new OraklError(OraklErrorCode.FailedToConnectAPI) + } else { + throw new OraklError(OraklErrorCode.GetReporterRequestFailed) + } } } @@ -92,8 +96,12 @@ export async function getReporter({ const endpoint = buildUrl(ORAKL_NETWORK_API_URL, `reporter/${id}`) return (await axios.get(endpoint))?.data } catch (e) { - logger?.error({ name: 'getReporter', file: FILE_NAME, ...e }, 'error') - throw new OraklError(OraklErrorCode.GetReporterRequestFailed) + logger?.error({ name: 'getReporters', file: FILE_NAME, ...e }, 'error') + if (e.code === 'ECONNREFUSED') { + throw new OraklError(OraklErrorCode.FailedToConnectAPI) + } else { + throw new OraklError(OraklErrorCode.GetReporterRequestFailed) + } } } @@ -131,7 +139,11 @@ export async function getReporterByOracleAddress({ return reporter[0] } catch (e) { logger.error({ name: 'getReportersByOracleAddress', file: FILE_NAME, ...e }, 'error') - throw new OraklError(OraklErrorCode.GetReporterRequestFailed) + if (e.code === 'ECONNREFUSED') { + throw new OraklError(OraklErrorCode.FailedToConnectAPI) + } else { + throw new OraklError(OraklErrorCode.GetReporterRequestFailed) + } } } diff --git a/core/src/errors.ts b/core/src/errors.ts index 864f76ce1..b43ecce6e 100644 --- a/core/src/errors.ts +++ b/core/src/errors.ts @@ -72,5 +72,6 @@ export enum OraklErrorCode { AxiosBadRequest, AxiosCanceledByUser, AxiosNotSupported, - AxiosInvalidUrl + AxiosInvalidUrl, + FailedToConnectAPI }