From 5d293659a82eef68c9cbef604ae6279c59ee9654 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Mon, 3 Jun 2024 16:30:07 -0700 Subject: [PATCH] Provide more debugging info when a snapshot gets set multiple times (improve #370). --- jvm/CHANGELOG.md | 1 + .../kotlin/com/diffplug/selfie/guts/WriteTracker.kt | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/jvm/CHANGELOG.md b/jvm/CHANGELOG.md index 027089b6..96ee2c32 100644 --- a/jvm/CHANGELOG.md +++ b/jvm/CHANGELOG.md @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Bump Kotlin to 2.0.0. ([#405](https://github.com/diffplug/selfie/pull/405)) ### Fixed - Do not remove stale snapshot files when readonly is true. ([#367](https://github.com/diffplug/selfie/pull/367)) +- Provide more debugging info when a snapshot gets set multiple times. (helps with [#370](https://github.com/diffplug/selfie/issues/370)) ## [2.0.2] - 2024-03-20 ### Fixed diff --git a/jvm/selfie-lib/src/commonMain/kotlin/com/diffplug/selfie/guts/WriteTracker.kt b/jvm/selfie-lib/src/commonMain/kotlin/com/diffplug/selfie/guts/WriteTracker.kt index 428b65ab..ebec0955 100644 --- a/jvm/selfie-lib/src/commonMain/kotlin/com/diffplug/selfie/guts/WriteTracker.kt +++ b/jvm/selfie-lib/src/commonMain/kotlin/com/diffplug/selfie/guts/WriteTracker.kt @@ -85,7 +85,12 @@ sealed class WriteTracker, V> { } if (existing.snapshot != snapshot) { throw layout.fs.assertFailed( - "Snapshot was set to multiple values!\n first time: ${existing.callStack.location.ideLink(layout)}\n this time: ${call.location.ideLink(layout)}\n$howToFix", + "Snapshot was set to multiple values!\n" + + " first value: ${existing.snapshot}\n" + + " this time: ${snapshot}\n" + + " first call: ${existing.callStack.ideLink(layout)}\n" + + " this call: ${call.ideLink(layout)}\n" + + "$howToFix", existing.snapshot, snapshot) } else if (!layout.allowMultipleEquivalentWritesToOneLocation) {