diff --git a/src/main/java/com/primefactorsolutions/service/CompilerService.java b/src/main/java/com/primefactorsolutions/service/CompilerService.java index 70b8450..ea657a2 100644 --- a/src/main/java/com/primefactorsolutions/service/CompilerService.java +++ b/src/main/java/com/primefactorsolutions/service/CompilerService.java @@ -47,17 +47,20 @@ public class CompilerService { final Class clazz = classLoader.loadClass(qualifiedClassName); Map results = Map.of(); - Method[] methods = clazz.getMethods(); - for (Method m : methods) { - if ("run".equals(m.getName())) { - try { + try { + Method[] methods = clazz.getMethods(); + for (Method m : methods) { + if ("run".equals(m.getName())) { results = (Map) m.invoke(null, new Object[]{}); - } catch (Exception e) { - results = Map.of("Exception: " + ExceptionUtils.getStackTrace(ExceptionUtils.getRootCause(e)), false); + break; } - - 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()