Skip to content

Commit f5983c5

Browse files
authored
Clarify exception recovery documentation regarding suppressed exceptions (#2544)
Fixes KT-44478
1 parent e25f627 commit f5983c5

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

docs/topics/debugging.md

+4
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ It is easy to demonstrate with actual stacktraces of the same program that await
4646

4747
The only downside of this approach is losing referential transparency of the exception.
4848

49+
> Note that suppressed exceptions are not copied and are left intact in the cause
50+
> in order to prevent cycles in the exceptions chain, obscure`[CIRCULAR REFERENCE]` messages
51+
> and even [crashes](https://jira.qos.ch/browse/LOGBACK-1027) in some frameworks
52+
4953
### Stacktrace recovery machinery
5054

5155
This section explains the inner mechanism of stacktrace recovery and can be skipped.

kotlinx-coroutines-core/common/src/Debug.common.kt

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public interface CopyableThrowable<T> where T : Throwable, T : CopyableThrowable
3535
* For better debuggability, it is recommended to use original exception as [cause][Throwable.cause] of the resulting one.
3636
* Stacktrace of copied exception will be overwritten by stacktrace recovery machinery by [Throwable.setStackTrace] call.
3737
* An exception can opt-out of copying by returning `null` from this function.
38+
* Suppressed exceptions of the original exception should not be copied in order to avoid circular exceptions.
3839
*/
3940
public fun createCopy(): T?
4041
}

0 commit comments

Comments
 (0)