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
@@ -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;
}
}
@@ -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