Fix long crash stack traces breaking the GitHub URL

This commit is contained in:
Keavon Chambers
2024-01-28 19:25:27 -08:00
parent 6b6accfb91
commit 8a6854e55b
+14 -1
View File
@@ -23,6 +23,7 @@ export function createPanicManager(editor: Editor, dialogState: DialogState) {
export function githubUrl(panicDetails: string): string {
const url = new URL("https://github.com/GraphiteEditor/Graphite/issues/new");
const buildUrl = (includeCrashReport: boolean) => {
let body = stripIndents`
**Describe the Crash**
Explain clearly what you were doing when the crash occurred.
@@ -45,8 +46,12 @@ export function githubUrl(panicDetails: string): string {
Copied from the crash dialog in the Graphite editor:
`;
const manualCopyStackTraceNotice = stripIndents`
Before submitting this bug, REPLACE THIS WITH THE LOG. Return to the editor and click "Copy Error Log" in the crash dialog and paste it in place of this text.
`;
body += "\n\n```\n";
body += panicDetails.trimEnd();
body += includeCrashReport ? panicDetails.trimEnd() : manualCopyStackTraceNotice;
body += "\n```";
const fields = {
@@ -64,4 +69,12 @@ export function githubUrl(panicDetails: string): string {
});
return url.toString();
};
let urlString = buildUrl(true);
if (urlString.length >= 8192) {
// Fall back to a shorter version if it exceeds GitHub limits of 8192 total characters
urlString = buildUrl(false);
}
return urlString;
}