on 42e34eb help sign in
bridge/src/components/GlobalErrorBoundary.js
74 lines 2.3 kB history raw
1import React, { useMemo } from 'react';
2import newGithubIssueUrl from 'new-github-issue-url';
3import { OutButton, RestartButton } from './Buttons';
4import { versionLabel } from 'lib/flags';
6const buildTitle = error => `Error Report: ${error.message}`;
8const buildBody = error => `\n
9<!-- Thanks for submitting this error! Can you help us identify the issue by providing additional context? -->
10\n
11## Context
12\n
13<!-- 1) What were you doing when you encountered this error? -->
14\n
15<!-- 2) If you're comfortable sharing (don't self-dox!), what Ethereum address were you logged in with? -->
16\n
17## Error\n\n
18\`\`\`
19${error.stack}
20\`\`\`
21\n
22In Bridge version ${versionLabel}.\n
23`;
25/**
26 * NOTE: we want to use as few normal components here as possible, since the
27 * error might have originated from within those components, making this
28 * whole error boundary useless.
29 */
30export default function GlobalErrorBoundary({ error }) {
31 const url = useMemo(
32 () =>
33 newGithubIssueUrl({
34 user: 'urbit',
35 repo: 'bridge',
36 labels: ['bug', 'error handling'],
37 title: buildTitle(error),
38 body: buildBody(error),
39 }),
40 [error]
41 );
43 return (
44 <div className="mw1 ph4">
45 <h2 className="mt8">
46 Bridge Error!{' '}
47 <span role="img" aria-label="a bridge on fire">
48 🌉🔥
49 </span>
50 </h2>
51 <p className="mt4 f5">
52 We caught an error thrown by the Bridge application client-side code.
53 <br />
54 <b>Your points and assets are most likely safe.</b>
55 </p>
56 <p className="mt4">
57 If you'd like to help us make Bridge better, you can submit the error
58 and your description of events to our GitHub issue tracker.
59 </p>
60 <OutButton href={url} solid>
61 Submit the Issue on GitHub
62 </OutButton>
63 <pre className="bg-gray1 mt4 p4 mono scroll-x">{error.stack}</pre>
64 <p className="mt4">
65 You can reload Bridge and retry the operation that caused an error. If
66 the error persists, please submit a bug report and we'll work with you
67 to resolve it!
68 </p>
69 <RestartButton onClick={() => document.location.reload()} solid success>
70 Reload Bridge
71 </RestartButton>
72 </div>
73 );