From ae9368388f1a2d08188fe955700c1c6e97eb0dff Mon Sep 17 00:00:00 2001 From: Siphalor Date: Sun, 24 May 2026 16:53:10 +0200 Subject: [PATCH] fix(serde-ext): Add paths to TweedReadIssue and TweedEntryWriteException --- CHANGELOG.md | 1 + .../extension/api/TweedEntryWriteException.java | 8 ++++---- .../extension/api/read/result/TweedReadIssue.java | 14 ++++++++++++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9200bf6..d3874c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `minecraft-fabric-helper`: Fixed missing new line in error log message. - `serde-extension`, `default-extensions`: Integrate path tracking into `ReadWriteExtension`, deprecate the existing `PatherExtension` +- `serde-extension`: Expose entry and value path in `TweedReadIssue` and the message of `TweedEntryWriteException`. - `type-utls`: Fixed missing `@Nullable` annotation on `ActualType#getAnnotation`. - `weaver-pojo`: Fixed `StringMapPojoWeaver` weaving entries without `@StringMapWeaving` annotation. diff --git a/tweed5/serde-extension/src/main/java/de/siphalor/tweed5/serde/extension/api/TweedEntryWriteException.java b/tweed5/serde-extension/src/main/java/de/siphalor/tweed5/serde/extension/api/TweedEntryWriteException.java index 7542512..00bd6ad 100644 --- a/tweed5/serde-extension/src/main/java/de/siphalor/tweed5/serde/extension/api/TweedEntryWriteException.java +++ b/tweed5/serde-extension/src/main/java/de/siphalor/tweed5/serde/extension/api/TweedEntryWriteException.java @@ -7,22 +7,22 @@ public class TweedEntryWriteException extends Exception { private final TweedWriteContext context; public TweedEntryWriteException(String message, TweedWriteContext context) { - super(message); + super("At " + context.currentValuePath() + ": " + message); this.context = context; } public TweedEntryWriteException(String message, Throwable cause, TweedWriteContext context) { - super(message, cause); + super("At " + context.currentValuePath() + ": " + message, cause); this.context = context; } public TweedEntryWriteException(String message, TweedEntryWriteException cause) { - super(message, cause); + super("At " + cause.context.currentValuePath() + ": " + message, cause); this.context = cause.context; } public TweedEntryWriteException(Throwable cause, TweedWriteContext context) { - super(cause); + super("At " + context.currentValuePath() + ": " + cause.getMessage(), cause); this.context = context; } } diff --git a/tweed5/serde-extension/src/main/java/de/siphalor/tweed5/serde/extension/api/read/result/TweedReadIssue.java b/tweed5/serde-extension/src/main/java/de/siphalor/tweed5/serde/extension/api/read/result/TweedReadIssue.java index 0c154db..7961337 100644 --- a/tweed5/serde-extension/src/main/java/de/siphalor/tweed5/serde/extension/api/read/result/TweedReadIssue.java +++ b/tweed5/serde-extension/src/main/java/de/siphalor/tweed5/serde/extension/api/read/result/TweedReadIssue.java @@ -2,6 +2,7 @@ package de.siphalor.tweed5.serde.extension.api.read.result; import de.siphalor.tweed5.serde.extension.api.TweedReadContext; +import de.siphalor.tweed5.serde.extension.api.path.EntryPath; import lombok.*; @RequiredArgsConstructor(access = AccessLevel.PRIVATE) @@ -10,13 +11,22 @@ public class TweedReadIssue { @Getter private final Exception exception; private final TweedReadContext readContext; + @Getter + private final EntryPath entryPath; + @Getter + private final EntryPath valuePath; public static TweedReadIssue error(String message, TweedReadContext readContext) { - return new TweedReadIssue(new Exception(message), readContext); + return error(new Exception(message), readContext); } public static TweedReadIssue error(Exception exception, TweedReadContext readContext) { - return new TweedReadIssue(exception, readContext); + return new TweedReadIssue( + exception, + readContext, + readContext.currentEntryPath(), + readContext.currentValuePath() + ); } @Override