From 61e38a443357afdec4516bfaa719d2116e49ae22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Javier=20Guzm=C3=A1n=20Jim=C3=A9nez?= <906599+javierguzman@users.noreply.github.com> Date: Fri, 20 Oct 2023 11:48:04 +0200 Subject: [PATCH] feat: add error boundary (#534) --- src/renderer/ErrorBoundary.jsx | 29 +++++++++++++++++++++++++++++ src/renderer/index.tsx | 13 ++++++++----- 2 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 src/renderer/ErrorBoundary.jsx diff --git a/src/renderer/ErrorBoundary.jsx b/src/renderer/ErrorBoundary.jsx new file mode 100644 index 000000000..a9191cd75 --- /dev/null +++ b/src/renderer/ErrorBoundary.jsx @@ -0,0 +1,29 @@ +/* eslint-disable */ +import React from "react"; + +class ErrorBoundary extends React.Component { + constructor(props) { + super(props); + this.state = { hasError: true, errorMessage: "" }; + } + + static getDerivedStateFromError(error) { + return { hasError: true, errorMessage: error.message }; + } + + render() { + if (this.state.hasError) { + return ( +
This wasn't supposed to happen. If you continue to see this message, please reach out to support.
+{this.state.errorMessage}
+