use of com.walmartlabs.concord.sdk.UserDefinedException in project concord by walmartlabs.
the class Main method main.
public static void main(String[] args) {
// determine current working directory, it should contain the payload
Path baseDir = Paths.get(System.getProperty("user.dir"));
try {
long t1 = System.currentTimeMillis();
// load the config
RunnerConfiguration runnerCfg = validate(loadRunnerCfg(args));
// TODO enable security manager
// load dependencies
List<URL> deps = loadDependencyList(runnerCfg);
if (runnerCfg.debug()) {
log.info("Effective dependencies:\n\t{}", deps.stream().map(URL::toString).collect(Collectors.joining("\n\t")));
}
// NOSONAR
URLClassLoader depsClassLoader = new URLClassLoader(deps.toArray(new URL[0]), Main.class.getClassLoader());
Thread.currentThread().setContextClassLoader(depsClassLoader);
// create the injector to wire up and initialize all dependencies
Injector injector = createInjector(runnerCfg, depsClassLoader, baseDir);
Main main = injector.getInstance(Main.class);
long t2 = System.currentTimeMillis();
if (runnerCfg.debug()) {
log.info("Runtime loaded in {}ms", (t2 - t1));
}
main.run(runnerCfg, baseDir);
// force exit (helps with runaway threads)
System.exit(0);
} catch (Throwable e) {
// catch both errors and exceptions
// try to unroll nested exceptions to get a meaningful one
Throwable t = unroll(e);
if (t instanceof UserDefinedException) {
log.error("{}", t.getMessage());
} else {
log.error("main -> unhandled exception", t);
}
saveLastError(baseDir, t);
System.exit(1);
}
}
Aggregations