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 com.primefactorsolutions.service.compiler.JavaSourceFromString;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.tools.DiagnosticCollector;
|
import javax.tools.DiagnosticCollector;
|
||||||
@ -49,7 +50,12 @@ public class CompilerService {
|
|||||||
Method[] methods = clazz.getMethods();
|
Method[] methods = clazz.getMethods();
|
||||||
for (Method m : methods) {
|
for (Method m : methods) {
|
||||||
if ("run".equals(m.getName())) {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user