fix empty results

This commit is contained in:
alex 2024-08-09 17:16:32 -04:00
parent 8955eeb70a
commit 9fee8f8a7e

View File

@ -47,17 +47,20 @@ public class CompilerService {
final Class<?> clazz = classLoader.loadClass(qualifiedClassName); final Class<?> clazz = classLoader.loadClass(qualifiedClassName);
Map<String, Boolean> results = Map.of(); Map<String, Boolean> results = Map.of();
Method[] methods = clazz.getMethods(); try {
for (Method m : methods) { Method[] methods = clazz.getMethods();
if ("run".equals(m.getName())) { for (Method m : methods) {
try { if ("run".equals(m.getName())) {
results = (Map<String, Boolean>) m.invoke(null, new Object[]{}); results = (Map<String, Boolean>) m.invoke(null, new Object[]{});
} catch (Exception e) { break;
results = Map.of("Exception: " + ExceptionUtils.getStackTrace(ExceptionUtils.getRootCause(e)), false);
} }
break;
} }
if (results.isEmpty()) {
results = Map.of("No existe ningun resultado. Verifique el metodo 'run()'.", false);
}
} catch (Exception e) {
results = Map.of("Exception: " + ExceptionUtils.getStackTrace(ExceptionUtils.getRootCause(e)), false);
} }
return Optional.of(results.entrySet().stream() return Optional.of(results.entrySet().stream()