From b48ab750f68f5b1a6ea50dd9f7f7c967088bf5c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Renaudeau?= Date: Fri, 6 Jul 2018 11:32:49 +0200 Subject: [PATCH] Include URL and method for debuggability --- src/api/network.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/api/network.js b/src/api/network.js index 64d510e1..8743b401 100644 --- a/src/api/network.js +++ b/src/api/network.js @@ -4,6 +4,7 @@ import { GET_CALLS_RETRY, GET_CALLS_TIMEOUT } from 'config/constants' import { retry } from 'helpers/promise' import logger from 'logger' import { createCustomErrorClass } from 'helpers/errors' +import anonymizer from 'helpers/anonymizer' export const LedgerAPIErrorWithMessage = createCustomErrorClass('LedgerAPIErrorWithMessage') export const LedgerAPIError = createCustomErrorClass('LedgerAPIError') @@ -34,12 +35,20 @@ const userFriendlyError = (p: Promise, { url, method, startTime }): Promis logger.warn("can't parse server result", e) } if (msg && msg[0] !== '<') { - errorToThrow = new LedgerAPIErrorWithMessage(msg) + errorToThrow = new LedgerAPIErrorWithMessage(msg, { + status, + url: anonymizer.url(url), + method, + }) } } } if (!errorToThrow) { - errorToThrow = new LedgerAPIError(`LedgerAPIError ${status}`, { status }) + errorToThrow = new LedgerAPIError(`LedgerAPIError ${status}`, { + status, + url: anonymizer.url(url), + method, + }) } logger.networkError({ status,