Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LuckySwap
interface
Commits
95db44e0
Unverified
Commit
95db44e0
authored
May 12, 2021
by
Moody Salem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add a little state to the automatic issue body
parent
7d45ff5c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
16 deletions
+36
-16
index.tsx
src/components/ErrorBoundary/index.tsx
+36
-16
No files found.
src/components/ErrorBoundary/index.tsx
View file @
95db44e0
import
React
,
{
ErrorInfo
}
from
'
react
'
import
store
,
{
AppState
}
from
'
../../state
'
import
{
ExternalLink
,
ThemedBackground
,
TYPE
}
from
'
../../theme
'
import
{
AutoColumn
}
from
'
../Column
'
import
styled
from
'
styled-components
'
...
...
@@ -114,26 +115,45 @@ export default class ErrorBoundary extends React.Component<unknown, ErrorBoundar
}
}
function
getRelevantState
():
null
|
keyof
AppState
{
const
path
=
window
.
location
.
hash
if
(
!
path
.
startsWith
(
'
#/
'
))
{
return
null
}
const
pieces
=
path
.
substring
(
2
).
split
(
/
[\/\\
?
]
/
)
switch
(
pieces
[
0
])
{
case
'
swap
'
:
return
'
swap
'
case
'
add
'
:
if
(
pieces
[
1
]
===
'
v2
'
)
return
'
mint
'
else
return
'
mintV3
'
case
'
remove
'
:
if
(
pieces
[
1
]
===
'
v2
'
)
return
'
burn
'
else
return
'
burnV3
'
}
return
null
}
function
issueBody
(
error
:
Error
):
string
{
if
(
!
error
)
throw
new
Error
(
'
no error to report
'
)
const
relevantState
=
getRelevantState
(
)
const
deviceData
=
getUserAgent
()
return
`
**Bug Description**
return
`
## URL
App crashed
**Steps to Reproduce**
1. Go to ...
2. Click on ...
...
**URL**
${
window
.
location
.
href
}
${
relevantState
?
`## \`
${
relevantState
}
\` state
\`\`\`json
${
JSON
.
stringify
(
store
.
getState
()[
relevantState
],
null
,
2
)}
\`\`\`
`
:
''
}
${
error
.
name
&&
`
**Error**
`
## Error
\`\`\`
${
error
.
name
}${
error
.
message
&&
`:
${
error
.
message
}
`
}
...
...
@@ -142,7 +162,7 @@ ${error.name}${error.message && `: ${error.message}`}
}
${
error
.
stack
&&
`
**Stacktrace**
`
## Stacktrace
\`\`\`
${
error
.
stack
}
...
...
@@ -151,9 +171,9 @@ ${error.stack}
}
${
deviceData
&&
`
**Device data**
`
## Device data
\`\`\`json
5
\`\`\`json
${
JSON
.
stringify
(
deviceData
,
null
,
2
)}
\`\`\`
`
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment