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;
import com.dfsek.terra.api.util.GlueList;
import java.util.List;
public class AttemptsFailedException extends RuntimeException {
public AttemptsFailedException() {
super();
}
private final List<Throwable> causes;
public AttemptsFailedException(String message) {
public AttemptsFailedException(String message, List<Throwable> causes) {
super(message);
this.causes = causes;
}
public AttemptsFailedException(String message, Throwable cause) {
super(message, cause);
}
public AttemptsFailedException(Throwable cause) {
super(cause);
public List<Throwable> getCauses() {
return new GlueList<>(causes);
}
}

View File

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

View File

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