From cc345946e66d1f32cd43490ad3895a4d590658f8 Mon Sep 17 00:00:00 2001 From: Mikhail Mikheev Date: Tue, 1 Jun 2021 14:10:57 +0400 Subject: [PATCH] Feature: Better error handling for Safe apps things (#2340) * handle request/app fetch errors * shorted extraMessage for app fetch error * use context instead of extra for safe app url exception when fetching * app -> safeApp for sentry context --- src/routes/safe/components/Apps/communicator.ts | 9 ++++++--- src/routes/safe/components/Apps/utils.ts | 8 +++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/routes/safe/components/Apps/communicator.ts b/src/routes/safe/components/Apps/communicator.ts index 95bd7a98..df31d8bb 100644 --- a/src/routes/safe/components/Apps/communicator.ts +++ b/src/routes/safe/components/Apps/communicator.ts @@ -69,9 +69,12 @@ class AppCommunicator { } } catch (err) { this.send(err.message, msg.data.id, true) - // TODO: Allow passing method/message as an extra context - // Tweak CodedException class to accept it as a second argument - logError(Errors._901, `${msg.data.method} ${err.message}`) + logError(Errors._901, err.message, { + contexts: { + safeApp: this.app, + request: msg.data, + }, + }) } } } diff --git a/src/routes/safe/components/Apps/utils.ts b/src/routes/safe/components/Apps/utils.ts index 506eabd1..feb0d6da 100644 --- a/src/routes/safe/components/Apps/utils.ts +++ b/src/routes/safe/components/Apps/utils.ts @@ -274,7 +274,13 @@ export const getAppInfoFromUrl = memoize( } return res } catch (error) { - logError(Errors._900, `${res.url}: ${error.message}`, undefined, false) + logError(Errors._900, error.message, { + contexts: { + safeApp: { + url: appUrl, + }, + }, + }) return res } },