Skip to content
This repository was archived by the owner on Jun 24, 2022. It is now read-only.

Commit

Permalink
Truncating error msg when opening GH issue via URL (#1472)
Browse files Browse the repository at this point in the history
# Summary

Closes #1460 

Truncating error msg and stack trace to 1000 chars to fit into URL

  # To Test
Repeat steps on #1460 

Or:

1. Use slippage of 1.11%
2. Pick both tokens
3. Insert an amount
* It'll force a hard error :)
  • Loading branch information
alfetopito authored Sep 27, 2021
1 parent 9ab9b1f commit e880e43
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/custom/components/ErrorBoundary/ErrorBoundaryMod.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ type ErrorBoundaryState = {
error: Error | null
}

function truncate(value?: string): string | undefined {
return value ? value.slice(0, 1000) : undefined
}

export default class ErrorBoundary extends React.Component<unknown, ErrorBoundaryState> {
constructor(props: unknown) {
super(props)
Expand Down Expand Up @@ -163,7 +167,7 @@ export default class ErrorBoundary extends React.Component<unknown, ErrorBoundar
<ExternalLink
id="create-github-issue-link"
href={`https://github.com/gnosis/cowswap/issues/new?assignees=&labels=🐞 Bug,🔥 Critical&body=${encodedBody}&title=${encodeURIComponent(
`Crash report: \`${error.name}${error.message && `: ${error.message}`}\``
`Crash report: \`${error.name}${error.message && `: ${truncate(error.message)}`}\``
)}`}
target="_blank"
>
Expand Down Expand Up @@ -232,7 +236,7 @@ ${
`## Error
\`\`\`
${error.name}${error.message && `: ${error.message}`}
${error.name}${error.message && `: ${truncate(error.message)}`}
\`\`\`
`
}
Expand All @@ -241,7 +245,7 @@ ${
`## Stacktrace
\`\`\`
${error.stack}
${truncate(error.stack)}
\`\`\`
`
}
Expand Down

0 comments on commit e880e43

Please sign in to comment.