FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Exceptionless.JavaScript/example/react/src/App.jsx at main · exceptionless/Exceptionless.JavaScript · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
exceptionless
/
Exceptionless.JavaScript
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
22
Star
60
Code
Issues
0
Pull requests
11
Actions
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
Exceptionless.JavaScript
/
example
/
react
/
src
/
App.jsx
Copy path
More file actions
More file actions
Latest commit
History
History
History
128 lines (116 loc) · 3.91 KB
Breadcrumbs
Exceptionless.JavaScript
/
example
/
react
/
src
/
App.jsx
Copy path
File metadata and controls
128 lines (116 loc) · 3.91 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import
React
,
{
Component
}
from
"react"
;
import
"./App.css"
;
import
{
Exceptionless
,
ExceptionlessErrorBoundary
}
from
"@exceptionless/react"
;
function
ExceptionlessExampleContent
(
{
error
,
message
,
errorInfo
,
onThrowComponentError
,
onUnhandledException
,
onSubmitMessage
,
onTryCatchExample
}
)
{
if
(
error
)
{
throw
new
Error
(
"I crashed!"
)
;
}
return
(
<
div
className
=
"App"
>
<
header
className
=
"App-header"
>
<
div
className
=
"container"
>
<
h1
className
=
"App-title"
>
Exceptionless React Sample
</
h1
>
<
p
>
By pressing the button below, an uncaught error will be thrown inside your component. This will automatically be sent to Exceptionless.
</
p
>
<
button
onClick
=
{
onThrowComponentError
}
>
Simulate Error
</
button
>
<
div
>
<
p
>
Throw an uncaught error and make sure Exceptionless tracks it.
</
p
>
<
button
onClick
=
{
onUnhandledException
}
>
Throw unhandled error
</
button
>
</
div
>
<
p
>
The following buttons simulated handled events outside the component.
</
p
>
<
button
onClick
=
{
onSubmitMessage
}
>
Submit Message
</
button
>
{
message
&&
(
<
p
>
Message sent to Exceptionless:
<
code
>
{
message
}
</
code
>
</
p
>
)
}
<
button
onClick
=
{
onTryCatchExample
}
>
Try/Catch Example
</
button
>
{
errorInfo
&&
(
<
p
>
Error message sent to Exceptionless:
<
code
>
{
errorInfo
}
</
code
>
</
p
>
)
}
</
div
>
</
header
>
</
div
>
)
;
}
function
ErrorFallback
(
{
onReset
}
)
{
return
(
<
div
className
=
"App"
>
<
header
className
=
"App-header"
>
<
div
className
=
"container error-container"
>
<
p
className
=
"error-eyebrow"
>
Component error captured
</
p
>
<
h1
className
=
"App-title"
>
Something went wrong
</
h1
>
<
p
>
The error was submitted to Exceptionless. You can reset this sample and keep testing without refreshing the page.
</
p
>
<
button
onClick
=
{
onReset
}
>
Try again
</
button
>
</
div
>
</
header
>
</
div
>
)
;
}
class
App
extends
Component
{
constructor
(
props
)
{
super
(
props
)
;
this
.
state
=
{
error
:
false
,
errorBoundaryKey
:
0
,
errorInfo
:
""
,
message
:
""
}
;
}
async
componentDidMount
(
)
{
await
Exceptionless
.
startup
(
(
c
)
=>
{
c
.
apiKey
=
"LhhP1C9gijpSKCslHHCvwdSIz298twx271nTest"
;
c
.
serverUrl
=
"https://ex.dev.localhost:7111"
;
c
.
useDebugLogger
(
)
;
c
.
defaultTags
.
push
(
"Example"
,
"React"
)
;
}
)
;
}
throwErrorInComponent
=
(
)
=>
{
this
.
setState
(
{
error
:
true
}
)
;
}
;
resetComponentError
=
(
)
=>
{
this
.
setState
(
(
state
)
=>
(
{
error
:
false
,
errorBoundaryKey
:
state
.
errorBoundaryKey
+
1
}
)
)
;
}
;
submitMessage
=
async
(
)
=>
{
const
message
=
"Hello, world!"
;
this
.
setState
(
{
message
:
""
,
errorInfo
:
""
}
)
;
await
Exceptionless
.
submitLog
(
message
)
;
this
.
setState
(
{
message
}
)
;
}
;
tryCatchExample
=
async
(
)
=>
{
try
{
this
.
setState
(
{
message
:
""
,
errorInfo
:
""
}
)
;
throw
new
Error
(
"Caught in the try/catch"
)
;
}
catch
(
error
)
{
this
.
setState
(
{
errorInfo
:
error
.
message
}
)
;
await
Exceptionless
.
submitException
(
error
)
;
}
}
;
unhandledExceptionExample
=
(
)
=>
{
throw
new
Error
(
"Unhandled exception"
)
;
}
;
render
(
)
{
return
(
<
ExceptionlessErrorBoundary
key
=
{
this
.
state
.
errorBoundaryKey
}
fallback
=
{
<
ErrorFallback
onReset
=
{
this
.
resetComponentError
}
/>
}
>
<
ExceptionlessExampleContent
error
=
{
this
.
state
.
error
}
message
=
{
this
.
state
.
message
}
errorInfo
=
{
this
.
state
.
errorInfo
}
onThrowComponentError
=
{
this
.
throwErrorInComponent
}
onUnhandledException
=
{
this
.
unhandledExceptionExample
}
onSubmitMessage
=
{
(
)
=>
{
void
this
.
submitMessage
(
)
;
}
}
onTryCatchExample
=
{
(
)
=>
{
void
this
.
tryCatchExample
(
)
;
}
}
/>
</
ExceptionlessErrorBoundary
>
)
;
}
}
export
default
App
;
Back
|
FazBrowse Home
|
New Git URL