fixed exception handler
This commit is contained in:
parent
6d0409c6c8
commit
0c19050436
@ -14,16 +14,15 @@ public class ExceptionService {
|
|||||||
if (exceptionMap != null) return;
|
if (exceptionMap != null) return;
|
||||||
exceptionMap = new HashMap<>();
|
exceptionMap = new HashMap<>();
|
||||||
|
|
||||||
var ref = new Reflections("ru.dragonestia.picker.api.exception");
|
var ref = new Reflections("ru.dragonestia.picker");
|
||||||
for (var clazz: ref.getTypesAnnotatedWith(ApiException.class)) {
|
for (var clazz: ref.getTypesAnnotatedWith(ApiException.class)) {
|
||||||
if (!clazz.isNestmateOf(RuntimeException.class)) continue;
|
|
||||||
|
|
||||||
exceptionMap.put(clazz.getSimpleName(), clazz);
|
exceptionMap.put(clazz.getSimpleName(), clazz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RuntimeException prepare(String ex, String message) {
|
public static RuntimeException prepare(String ex, String message) {
|
||||||
try {
|
try {
|
||||||
|
System.out.println(exceptionMap);
|
||||||
return (RuntimeException) exceptionMap.getOrDefault(ex, UnknownException.class)
|
return (RuntimeException) exceptionMap.getOrDefault(ex, UnknownException.class)
|
||||||
.getConstructor(String.class)
|
.getConstructor(String.class)
|
||||||
.newInstance(message);
|
.newInstance(message);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user