@@ -3,9 +3,12 @@ import { observer } from 'mobx-react';
3
3
import { observable , action } from 'mobx' ;
4
4
5
5
import { styled } from '../styles' ;
6
- import { Sentry , isSentryInitialized } from '../errors' ;
6
+ import { Sentry } from '../errors' ;
7
+ import { isErrorLike } from '../util/error' ;
7
8
import { trackEvent } from '../metrics' ;
8
9
10
+ import { Button , ButtonLink } from './common/inputs' ;
11
+
9
12
const ErrorOverlay = styled ( ( props : {
10
13
className ?: string ,
11
14
children : React . ReactNode
@@ -25,43 +28,40 @@ const ErrorOverlay = styled((props: {
25
28
align-items: center;
26
29
justify-content: center;
27
30
31
+ overflow-y: auto;
32
+
28
33
color: ${ p => p . theme . mainColor } ;
29
34
30
35
h1 {
31
- font-size: 300px ;
36
+ font-size: ${ p => p . theme . screamingHeadingSize } ;
32
37
font-weight: bold;
33
- line-height: 230px;
34
38
margin-bottom: 50px;
35
39
}
36
40
37
- p {
38
- font-size: 50px ;
41
+ h2 {
42
+ font-size: ${ p => p . theme . loudHeadingSize } ;
39
43
margin-bottom: 50px;
40
44
}
41
45
42
- button {
46
+ button, a {
43
47
display: block;
44
- margin: 0 auto 40px;
45
-
46
- color: ${ p => p . theme . mainColor } ;
47
- background-color: ${ p => p . theme . mainBackground } ;
48
- box-shadow: 0 2px 10px 0 rgba(0,0,0,${ p => p . theme . boxShadowAlpha } );
49
- border-radius: 4px;
50
- border: none;
48
+ margin: 40px 40px 0;
51
49
52
50
padding: 20px;
53
51
54
- font-size: 50px ;
52
+ font-size: ${ p => p . theme . loudHeadingSize } ;
55
53
font-weight: bolder;
54
+ }
55
+ ` ;
56
56
57
- &:not(:disabled) {
58
- cursor: pointer;
57
+ const ButtonContainer = styled . div `
58
+ display: flex;
59
+ flex-wrap: wrap;
60
+ ` ;
59
61
60
- &:hover {
61
- color: ${ p => p . theme . popColor } ;
62
- }
63
- }
64
- }
62
+ const ErrorOutput = styled . code `
63
+ font-family: ${ p => p . theme . monoFontFamily } ;
64
+ white-space: preserve;
65
65
` ;
66
66
67
67
@observer
@@ -70,9 +70,6 @@ export class ErrorBoundary extends React.Component {
70
70
@observable
71
71
private error : Error | undefined ;
72
72
73
- @observable
74
- private feedbackSent : boolean = false ;
75
-
76
73
@action
77
74
componentDidCatch ( error : Error , errorInfo : any ) {
78
75
this . error = error ;
@@ -96,26 +93,25 @@ export class ErrorBoundary extends React.Component {
96
93
< h1 >
97
94
Oh no!
98
95
</ h1 >
99
- < p >
96
+ < h2 >
100
97
Sorry, it's all gone wrong.
101
- </ p >
102
- < div >
103
- { isSentryInitialized ( ) &&
104
- < button disabled = { this . feedbackSent } onClick = { this . sendFeedback } >
105
- Tell us what happened
106
- </ button >
107
- }
108
- < button onClick = { ( ) => window . location . reload ( ) } >
98
+ </ h2 >
99
+ { isErrorLike ( this . error ) && < ErrorOutput >
100
+ { this . error . stack ?? this . error . message }
101
+ </ ErrorOutput > }
102
+ < ButtonContainer >
103
+ < ButtonLink href = {
104
+ `https://github.com/httptoolkit/httptoolkit/issues/new?template=bug.yml&title=[UI Crash]%3A+${
105
+ this . error . message || ''
106
+ } `
107
+ } >
108
+ Tell us what happened
109
+ </ ButtonLink >
110
+ < Button onClick = { ( ) => window . location . reload ( ) } >
109
111
Reload HTTP Toolkit
110
- </ button >
111
- </ div >
112
+ </ Button >
113
+ </ ButtonContainer >
112
114
</ ErrorOverlay >
113
115
) : this . props . children ;
114
116
}
115
-
116
- @action . bound
117
- sendFeedback ( ) {
118
- Sentry . showReportDialog ( ) ;
119
- this . feedbackSent = true ;
120
- }
121
117
}
0 commit comments