handle exam exceptions
This commit is contained in:
parent
ed9cc26831
commit
8955eeb70a
@ -4,6 +4,7 @@ import com.primefactorsolutions.service.compiler.InMemoryFileManager;
|
||||
import com.primefactorsolutions.service.compiler.JavaSourceFromString;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.tools.DiagnosticCollector;
|
||||
@ -49,7 +50,12 @@ public class CompilerService {
|
||||
Method[] methods = clazz.getMethods();
|
||||
for (Method m : methods) {
|
||||
if ("run".equals(m.getName())) {
|
||||
results = (Map<String, Boolean>) m.invoke(null, new Object[] {});
|
||||
try {
|
||||
results = (Map<String, Boolean>) m.invoke(null, new Object[]{});
|
||||
} catch (Exception e) {
|
||||
results = Map.of("Exception: " + ExceptionUtils.getStackTrace(ExceptionUtils.getRootCause(e)), false);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user