Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: trim stacktrace to fit in GH issue description #99

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/main/kotlin/com/vaadin/plugin/copilot/CopilotErrorHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import java.awt.Component

class CopilotErrorHandler : ErrorReportSubmitter() {

private val ghMaxBodyLength = 5000

private val url = "https://github.com/vaadin/intellij-plugin/issues/new"

override fun getReportActionText(): String {
Expand All @@ -22,10 +24,14 @@ class CopilotErrorHandler : ErrorReportSubmitter() {
parentComponent: Component,
consumer: Consumer<in SubmittedReportInfo>,
): Boolean {
val throwableText = events.iterator().next().throwableText
var throwableText = events.iterator().next().throwableText
val firstLine = throwableText.split("\\n".toRegex(), 2)[0].trim()
val appName = ApplicationInfo.getInstance().fullApplicationName

if (throwableText.length > ghMaxBodyLength) {
throwableText = throwableText.substring(0, ghMaxBodyLength)
}

var body =
"Plugin version: **${pluginDescriptor.version}**\n" +
"IDE version: **$appName**\n" +
Expand All @@ -35,7 +41,7 @@ class CopilotErrorHandler : ErrorReportSubmitter() {
body += "Additional info:\n" + "> ${additionalInfo.replace("\\n+".toRegex(), "\n")}" + "\n\n"
}

body += "Stacktrace:\n" + "```\n" + throwableText + "\n```"
body += "Stacktrace:\n```\n$throwableText\n```"

val title = "[Error report] $firstLine"
BrowserUtil.browse("$url?title=$title&body=$body")
Expand Down