From ff70c654a20543fa8af017d73356e62b465e1d7c Mon Sep 17 00:00:00 2001
From: Neil <55785687+carkom@users.noreply.github.com>
Date: Fri, 22 Mar 2024 16:03:47 +0000
Subject: [PATCH] Custom Reports Error Catch (#2492)

* Error Catch

* notes

* fixes
---
 .../reports/reports/CustomReportListCards.tsx | 42 +++++++++++++------
 upcoming-release-notes/2492.md                |  6 +++
 2 files changed, 35 insertions(+), 13 deletions(-)
 create mode 100644 upcoming-release-notes/2492.md

diff --git a/packages/desktop-client/src/components/reports/reports/CustomReportListCards.tsx b/packages/desktop-client/src/components/reports/reports/CustomReportListCards.tsx
index 6111d9b40..0aeacba2f 100644
--- a/packages/desktop-client/src/components/reports/reports/CustomReportListCards.tsx
+++ b/packages/desktop-client/src/components/reports/reports/CustomReportListCards.tsx
@@ -1,9 +1,10 @@
 import React, { createRef, useMemo, useState } from 'react';
+import { ErrorBoundary } from 'react-error-boundary';
 
 import { send, sendCatch } from 'loot-core/platform/client/fetch/index';
 import { type CustomReportEntity } from 'loot-core/types/models/reports';
 
-import { styles } from '../../../style';
+import { styles } from '../../../style/index';
 import { theme } from '../../../style/theme';
 import { Block } from '../../common/Block';
 import { Menu } from '../../common/Menu';
@@ -56,6 +57,19 @@ function index(data: CustomReportEntity[]): { [key: string]: boolean }[] {
   }, []);
 }
 
+function ErrorFallback() {
+  return (
+    <>
+      <div>
+        <br />
+      </div>
+      <Text style={{ ...styles.mediumText, color: theme.errorText }}>
+        There was a problem loading your report
+      </Text>
+    </>
+  );
+}
+
 export function CustomReportListCards({
   reports,
 }: {
@@ -193,18 +207,20 @@ export function CustomReportListCards({
                       </View>
 
                       {report.data ? (
-                        <ChooseGraph
-                          startDate={report.startDate}
-                          endDate={report.endDate}
-                          data={report.data}
-                          mode={report.mode}
-                          graphType={report.graphType}
-                          balanceType={report.balanceType}
-                          groupBy={report.groupBy}
-                          interval={report.interval}
-                          compact={true}
-                          style={{ height: 'auto', flex: 1 }}
-                        />
+                        <ErrorBoundary FallbackComponent={ErrorFallback}>
+                          <ChooseGraph
+                            startDate={report.startDate}
+                            endDate={report.endDate}
+                            data={report.data}
+                            mode={report.mode}
+                            graphType={report.graphType}
+                            balanceType={report.balanceType}
+                            groupBy={report.groupBy}
+                            interval={report.interval}
+                            compact={true}
+                            style={{ height: 'auto', flex: 1 }}
+                          />
+                        </ErrorBoundary>
                       ) : (
                         <LoadingIndicator />
                       )}
diff --git a/upcoming-release-notes/2492.md b/upcoming-release-notes/2492.md
new file mode 100644
index 000000000..c6575c342
--- /dev/null
+++ b/upcoming-release-notes/2492.md
@@ -0,0 +1,6 @@
+---
+category: Bugfix
+authors: [carkom]
+---
+
+Error catch for reports overview page.
-- 
GitLab