Skip to content

Commit

Permalink
push fe errors to sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
NickTracker committed Oct 4, 2024
1 parent 73c029f commit 4eb6d50
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
17 changes: 11 additions & 6 deletions client/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from "react";
import ReactDOM from "react-dom/client";
import "./index.css";
import App from "./App";
import reportWebVitals from "./reportWebVitals";

import * as Sentry from "@sentry/react";

Expand All @@ -20,11 +19,17 @@ Sentry.init({
const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(
<React.StrictMode>
<App />
<Sentry.ErrorBoundary fallback={<ErrorFallback />}>
<App />
</Sentry.ErrorBoundary>
</React.StrictMode>
);

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();
function ErrorFallback({error}) {
return (
<div>
<h1>Oops! Something went wrong.</h1>
<pre>{error.message}</pre>
</div>
);
}
8 changes: 6 additions & 2 deletions client/src/pages/Prospecting/Prospecting.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,9 @@ const Prospecting = () => {
setError(response.message);
}
} catch (err) {
setError("An error occurred while fetching data.");
setError(`An error occurred while fetching data: ${err.message}`);
console.error("Error details:", err);
throw err;
} finally {
setLoading(false);
setSummaryLoading(false);
Expand Down Expand Up @@ -294,7 +296,8 @@ const Prospecting = () => {
setError(response.message);
}
} catch (err) {
setError("An error occurred while fetching data.");
setError(`An error occurred while fetching data: ${err.message}`);
console.error("Error details:", err);
} finally {
setTableLoading(false);
}
Expand Down Expand Up @@ -360,6 +363,7 @@ const Prospecting = () => {
await fetchData(false, period, filteredIds);
} catch (err) {
setError(`An error occurred while generating the summary. ${err}`);
throw err;
} finally {
setSummaryLoading(false);
}
Expand Down

0 comments on commit 4eb6d50

Please sign in to comment.