Skip to content

Commit 56f8352

Browse files
committed
Simplify fixTypeEverywhere by directly returning Optional from DataResult#result and removing redundant error handling.
1 parent 06feff8 commit 56f8352

1 file changed

Lines changed: 2 additions & 10 deletions

File tree

  • aether-datafixers-api/src/main/java/de/splatgames/aether/datafixers/api/fix

aether-datafixers-api/src/main/java/de/splatgames/aether/datafixers/api/fix/Fixes.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -203,18 +203,10 @@ public Optional<Typed<?>> rewrite(@NotNull final Type<?> inputType,
203203
}
204204

205205
final DataResult<Dynamic<T>> encodeResult = input.encode(ops);
206-
final DataResult<Typed<?>> result = encodeResult.flatMap(dynamic -> {
206+
return encodeResult.flatMap(dynamic -> {
207207
final Dynamic<?> transformed = rewrite.apply(dynamic);
208208
return ((Type) type).read(transformed);
209-
}).map(newValue -> new Typed<>((Type) type, newValue));
210-
211-
final Typed<?> value = result.getOrThrow(false, error -> {
212-
throw new IllegalStateException(
213-
"Error applying fixTypeEverywhere rule '" + name + "' to type " + type + ": " + error
214-
);
215-
});
216-
217-
return Optional.of(value);
209+
}).map(newValue -> new Typed<>((Type) type, newValue)).result();
218210
}
219211

220212
@Override

0 commit comments

Comments
 (0)