From e880e43e1bbe60979bc2f2dea0dc55cbc8fe20ee Mon Sep 17 00:00:00 2001 From: Leandro Boscariol Date: Mon, 27 Sep 2021 10:27:19 -0700 Subject: [PATCH] Truncating error msg when opening GH issue via URL (#1472) # 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 :) --- .../components/ErrorBoundary/ErrorBoundaryMod.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/custom/components/ErrorBoundary/ErrorBoundaryMod.tsx b/src/custom/components/ErrorBoundary/ErrorBoundaryMod.tsx index 3cda945e3..7c7172067 100644 --- a/src/custom/components/ErrorBoundary/ErrorBoundaryMod.tsx +++ b/src/custom/components/ErrorBoundary/ErrorBoundaryMod.tsx @@ -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 { constructor(props: unknown) { super(props) @@ -163,7 +167,7 @@ export default class ErrorBoundary extends React.Component @@ -232,7 +236,7 @@ ${ `## Error \`\`\` -${error.name}${error.message && `: ${error.message}`} +${error.name}${error.message && `: ${truncate(error.message)}`} \`\`\` ` } @@ -241,7 +245,7 @@ ${ `## Stacktrace \`\`\` -${error.stack} +${truncate(error.stack)} \`\`\` ` }