From 7a3cc4e040321c037dfdd135f8c115279a25326b Mon Sep 17 00:00:00 2001 From: Bijin A B <4bijin@gmail.com> Date: Mon, 22 Apr 2024 00:11:51 +0530 Subject: [PATCH] fix: error boundary adding return-to-app and force-quit options (#2131) * fix: error boundary adding return-to-app and force-quit options * fix: method context * fix: method context * chore: increased print width to 200 in prettier * chore: reverted the prettier printWidth increase * feat: remove box-shadow from error boundary message layout --------- Co-authored-by: Anoop M D --- .../src/pages/ErrorBoundary/index.js | 54 +++++++++++++++---- packages/bruno-electron/src/ipc/collection.js | 4 ++ 2 files changed, 48 insertions(+), 10 deletions(-) diff --git a/packages/bruno-app/src/pages/ErrorBoundary/index.js b/packages/bruno-app/src/pages/ErrorBoundary/index.js index 3b45122ab..e0550bf48 100644 --- a/packages/bruno-app/src/pages/ErrorBoundary/index.js +++ b/packages/bruno-app/src/pages/ErrorBoundary/index.js @@ -1,5 +1,7 @@ import React from 'react'; +import Bruno from 'components/Bruno/index'; + class ErrorBoundary extends React.Component { constructor(props) { super(props); @@ -14,29 +16,61 @@ class ErrorBoundary extends React.Component { } componentDidCatch(error, errorInfo) { console.log({ error, errorInfo }); + this.setState({ hasError: true, error, errorInfo }); } + + returnToApp() { + const { ipcRenderer } = window; + ipcRenderer.invoke('open-file'); + + this.setState({ hasError: false, error: null, errorInfo: null }); + } + + forceQuit() { + const { ipcRenderer } = window; + ipcRenderer.invoke('main:force-quit'); + } + render() { if (this.state.hasError) { return ( -
-
+
+
+
+ +
+

Oops! Something went wrong

-

{this.state.error && this.state.error.toString()}

- {this.state.error && this.state.error.stack && ( -
{this.state.error.stack}
- )} +

+ If you are using an official production build: the above error is most likely a bug! +
+ Please report this under: + + https://github.com/usebruno/bruno/issues + +

+ + +
); } + return this.props.children; } } diff --git a/packages/bruno-electron/src/ipc/collection.js b/packages/bruno-electron/src/ipc/collection.js index ae47d6e06..ff570ca9f 100644 --- a/packages/bruno-electron/src/ipc/collection.js +++ b/packages/bruno-electron/src/ipc/collection.js @@ -628,6 +628,10 @@ const registerMainEventHandlers = (mainWindow, watcher, lastOpenedCollections) = ipcMain.handle('main:complete-quit-flow', () => { mainWindow.destroy(); }); + + ipcMain.handle('main:force-quit', () => { + process.exit(); + }); }; const registerCollectionsIpc = (mainWindow, watcher, lastOpenedCollections) => {