From 3b142fb783a8e7d656daaa4defccdc49b3cba122 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dafydd=20Ll=C5=B7r=20Pearson?= <DafyddLlyr@gmail.com>
Date: Sat, 7 Oct 2023 11:56:26 +0100
Subject: [PATCH] wip: Logging, trycatch

---
 editor.planx.uk/src/routes/index.tsx          |  9 +++-
 .../src/routes/views/standalone.tsx           | 42 +++++++++++--------
 2 files changed, 32 insertions(+), 19 deletions(-)

diff --git a/editor.planx.uk/src/routes/index.tsx b/editor.planx.uk/src/routes/index.tsx
index 9acce1e60f..cbcb28b0f5 100644
--- a/editor.planx.uk/src/routes/index.tsx
+++ b/editor.planx.uk/src/routes/index.tsx
@@ -1,3 +1,4 @@
+import { logger } from "airbrake";
 import { lazy, map, mount, redirect, route } from "navi";
 import * as React from "react";
 
@@ -58,7 +59,13 @@ const editorRoutes = mount({
 
 const mountPayRoutes = () =>
   map(async () => {
-    return lazy(() => import("./pay"));
+    try {
+      return lazy(() => import("./pay"));
+    } catch (error) {
+      console.log("ERROR MOUNTING PAY ROUTES");
+      logger.notify(error);
+      throw Error(`error in pay mount: ${error}`);
+    }
   });
 
 export default isPreviewOnlyDomain
diff --git a/editor.planx.uk/src/routes/views/standalone.tsx b/editor.planx.uk/src/routes/views/standalone.tsx
index 9169cde616..a906eb1113 100644
--- a/editor.planx.uk/src/routes/views/standalone.tsx
+++ b/editor.planx.uk/src/routes/views/standalone.tsx
@@ -1,3 +1,4 @@
+import { logger } from "airbrake";
 import gql from "graphql-tag";
 import { publicClient } from "lib/graphql";
 import { NaviRequest, NotFoundError } from "navi";
@@ -19,27 +20,32 @@ interface StandaloneViewData {
  * Fetches all necessary data, and sets up layout for a standalone page
  */
 const standaloneView = async (req: NaviRequest) => {
-  const flowSlug = req.params.flow.split(",")[0];
-  const teamSlug =
-    req.params.team || (await getTeamFromDomain(window.location.hostname));
-  const data = await fetchDataForStandaloneView(flowSlug, teamSlug);
+  try {
+    const flowSlug = req.params.flow.split(",")[0];
+    const teamSlug =
+      req.params.team || (await getTeamFromDomain(window.location.hostname));
+    const data = await fetchDataForStandaloneView(flowSlug, teamSlug);
 
-  const {
-    flows: [{ team, settings: flowSettings }],
-    globalSettings,
-  } = data;
+    const {
+      flows: [{ team, settings: flowSettings }],
+      globalSettings,
+    } = data;
 
-  const state = useStore.getState();
-  state.setFlowNameFromSlug(flowSlug);
-  state.setGlobalSettings(globalSettings[0]);
-  state.setFlowSettings(flowSettings);
-  state.setTeam(team);
+    const state = useStore.getState();
+    state.setFlowNameFromSlug(flowSlug);
+    state.setGlobalSettings(globalSettings[0]);
+    state.setFlowSettings(flowSettings);
+    state.setTeam(team);
 
-  return (
-    <PublicLayout>
-      <View />
-    </PublicLayout>
-  );
+    return (
+      <PublicLayout>
+        <View />
+      </PublicLayout>
+    );
+  } catch (error) {
+    console.log("ERROR IN STANDALONE VIEW: ", error);
+    logger.notify(error);
+  }
 };
 
 const fetchDataForStandaloneView = async (