mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-04 00:45:57 +00:00
improve registry load error message
This commit is contained in:
parent
d7811959fa
commit
1892dd1c37
@ -11,6 +11,7 @@ import java.util.Set;
|
|||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
import java.util.stream.Collector;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import com.dfsek.terra.api.registry.OpenRegistry;
|
import com.dfsek.terra.api.registry.OpenRegistry;
|
||||||
@ -37,14 +38,13 @@ public class OpenRegistryImpl<T> implements OpenRegistry<T> {
|
|||||||
@Override
|
@Override
|
||||||
public T load(AnnotatedType type, Object o, ConfigLoader configLoader) throws LoadException {
|
public T load(AnnotatedType type, Object o, ConfigLoader configLoader) throws LoadException {
|
||||||
T obj = get((String) o);
|
T obj = get((String) o);
|
||||||
StringBuilder keys = new StringBuilder("[");
|
String list = objects.keySet().stream().reduce("", (a, b) -> a + "\n - " + b);
|
||||||
|
|
||||||
objects.keySet().forEach(key -> keys.append(key).append(", "));
|
if(objects.isEmpty()) list = "[ ]";
|
||||||
|
|
||||||
if(obj == null)
|
if(obj == null)
|
||||||
throw new LoadException("No such " + type.getType().getTypeName() + " matching \"" + o +
|
throw new LoadException("No such " + type.getType().getTypeName() + " matching \"" + o +
|
||||||
"\" was found in this registry. Registry contains items: " + keys.substring(0, keys.length() - 2) +
|
"\" was found in this registry. Registry contains items: " + list);
|
||||||
"]");
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user