fix(serde-ext): Add paths to TweedReadIssue and TweedEntryWriteException

This commit is contained in:
2026-05-24 16:53:10 +02:00
parent f22c359a1c
commit ae9368388f
3 changed files with 17 additions and 6 deletions
+1
View File
@@ -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. - `minecraft-fabric-helper`: Fixed missing new line in error log message.
- `serde-extension`, `default-extensions`: Integrate path tracking into `ReadWriteExtension`, deprecate the existing - `serde-extension`, `default-extensions`: Integrate path tracking into `ReadWriteExtension`, deprecate the existing
`PatherExtension` `PatherExtension`
- `serde-extension`: Expose entry and value path in `TweedReadIssue` and the message of `TweedEntryWriteException`.
- `type-utls`: Fixed missing `@Nullable` annotation on `ActualType#getAnnotation`. - `type-utls`: Fixed missing `@Nullable` annotation on `ActualType#getAnnotation`.
- `weaver-pojo`: Fixed `StringMapPojoWeaver` weaving entries without `@StringMapWeaving` annotation. - `weaver-pojo`: Fixed `StringMapPojoWeaver` weaving entries without `@StringMapWeaving` annotation.
@@ -7,22 +7,22 @@ public class TweedEntryWriteException extends Exception {
private final TweedWriteContext context; private final TweedWriteContext context;
public TweedEntryWriteException(String message, TweedWriteContext context) { public TweedEntryWriteException(String message, TweedWriteContext context) {
super(message); super("At " + context.currentValuePath() + ": " + message);
this.context = context; this.context = context;
} }
public TweedEntryWriteException(String message, Throwable cause, TweedWriteContext context) { public TweedEntryWriteException(String message, Throwable cause, TweedWriteContext context) {
super(message, cause); super("At " + context.currentValuePath() + ": " + message, cause);
this.context = context; this.context = context;
} }
public TweedEntryWriteException(String message, TweedEntryWriteException cause) { public TweedEntryWriteException(String message, TweedEntryWriteException cause) {
super(message, cause); super("At " + cause.context.currentValuePath() + ": " + message, cause);
this.context = cause.context; this.context = cause.context;
} }
public TweedEntryWriteException(Throwable cause, TweedWriteContext context) { public TweedEntryWriteException(Throwable cause, TweedWriteContext context) {
super(cause); super("At " + context.currentValuePath() + ": " + cause.getMessage(), cause);
this.context = context; this.context = context;
} }
} }
@@ -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.TweedReadContext;
import de.siphalor.tweed5.serde.extension.api.path.EntryPath;
import lombok.*; import lombok.*;
@RequiredArgsConstructor(access = AccessLevel.PRIVATE) @RequiredArgsConstructor(access = AccessLevel.PRIVATE)
@@ -10,13 +11,22 @@ public class TweedReadIssue {
@Getter @Getter
private final Exception exception; private final Exception exception;
private final TweedReadContext readContext; private final TweedReadContext readContext;
@Getter
private final EntryPath entryPath;
@Getter
private final EntryPath valuePath;
public static TweedReadIssue error(String message, TweedReadContext readContext) { 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) { public static TweedReadIssue error(Exception exception, TweedReadContext readContext) {
return new TweedReadIssue(exception, readContext); return new TweedReadIssue(
exception,
readContext,
readContext.currentEntryPath(),
readContext.currentValuePath()
);
} }
@Override @Override