Skip to content

Commit 0dee20f

Browse files
committed
Safe
1 parent 79d1e63 commit 0dee20f

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

plugins/amazonq/chat/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonqFeatureDev/controller/FeatureDevControllerExtensions.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,12 +292,13 @@ private fun FeatureDevController.openChatNotificationAction() =
292292
// Should include error messages only for safe exceptions
293293
// i.e. exceptions with deterministic error messages and do not include sensitive data
294294
private fun getStackTraceForError(error: Throwable): String {
295+
val recursionLimit = 3
295296
val writer = StringWriter()
296297
val printer = PrintWriter(writer)
297298
val seenExceptions = mutableSetOf<Throwable>()
298299

299-
fun printExceptionDetails(throwable: Throwable, prefix: String = "") {
300-
if (throwable in seenExceptions) {
300+
fun printExceptionDetails(throwable: Throwable, depth: Int, prefix: String = "") {
301+
if (depth >= recursionLimit || throwable in seenExceptions) {
301302
return
302303
}
303304
seenExceptions.add(throwable)
@@ -332,15 +333,15 @@ private fun getStackTraceForError(error: Throwable): String {
332333

333334
throwable.cause?.let { cause ->
334335
printer.println("$prefix\tCaused by: ")
335-
printExceptionDetails(cause, "$prefix\t")
336+
printExceptionDetails(cause, depth + 1, "$prefix\t")
336337
}
337338

338339
throwable.suppressed.forEach { suppressed ->
339340
printer.println("$prefix\tSuppressed: ")
340-
printExceptionDetails(suppressed, "$prefix\t")
341+
printExceptionDetails(suppressed, depth + 1, "$prefix\t")
341342
}
342343
}
343344

344-
printExceptionDetails(error)
345+
printExceptionDetails(error, 0)
345346
return writer.toString()
346347
}

0 commit comments

Comments
 (0)