fix minor version issues

This commit is contained in:
dfsek
2021-01-10 16:55:49 -07:00
parent 12ff9cc146
commit 27aeb73157
3 changed files with 12 additions and 21 deletions

View File

@@ -1,19 +1,18 @@
package com.dfsek.terra.api.transform; package com.dfsek.terra.api.transform;
import com.dfsek.terra.api.util.GlueList;
import java.util.List;
public class AttemptsFailedException extends RuntimeException { public class AttemptsFailedException extends RuntimeException {
public AttemptsFailedException() { private final List<Throwable> causes;
super();
}
public AttemptsFailedException(String message) { public AttemptsFailedException(String message, List<Throwable> causes) {
super(message); super(message);
this.causes = causes;
} }
public AttemptsFailedException(String message, Throwable cause) { public List<Throwable> getCauses() {
super(message, cause); return new GlueList<>(causes);
}
public AttemptsFailedException(Throwable cause) {
super(cause);
} }
} }

View File

@@ -1,7 +1,5 @@
package com.dfsek.terra.api.transform; package com.dfsek.terra.api.transform;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@@ -28,7 +26,7 @@ public class Transformer<F, T> {
* @return Result * @return Result
*/ */
public T translate(F from) { public T translate(F from) {
List<Exception> exceptions = new ArrayList<>(); List<Throwable> exceptions = new ArrayList<>();
for(Map.Entry<Transform<F, T>, List<Validator<T>>> transform : transformers.entrySet()) { for(Map.Entry<Transform<F, T>, List<Validator<T>>> transform : transformers.entrySet()) {
try { try {
T result = transform.getKey().transform(from); T result = transform.getKey().transform(from);
@@ -42,13 +40,7 @@ public class Transformer<F, T> {
exceptions.add(exception); exceptions.add(exception);
} }
} }
StringBuilder exBuilder = new StringBuilder("Could not transform input; all attempts failed: ").append(from.toString()).append("\n"); throw new AttemptsFailedException("Could not transform input; all attempts failed: " + from.toString() + "\n", exceptions);
for(Exception exception : exceptions) {
StringWriter writer = new StringWriter();
exception.printStackTrace(new PrintWriter(writer));
exBuilder.append("\n").append(writer.toString());
}
throw new AttemptsFailedException(exBuilder.toString());
} }
/** /**

View File

@@ -57,7 +57,7 @@ public class TreeRegistry extends TerraRegistry<Tree> {
private void addTree(String id) { private void addTree(String id) {
try { try {
add(id, main.getWorldHandle().getTree(id)); add(id, main.getWorldHandle().getTree(id));
} catch(IllegalArgumentException e) { } catch(Exception e) {
main.getLogger().warning("Unable to load tree " + id + ": " + e.getMessage()); main.getLogger().warning("Unable to load tree " + id + ": " + e.getMessage());
} }
} }