diff --git a/spek-ide-plugin-interop-jvm/src/main/kotlin/org/spekframework/ide/console.kt b/spek-ide-plugin-interop-jvm/src/main/kotlin/org/spekframework/ide/console.kt index 91aaa9f0a..bb729ed5f 100644 --- a/spek-ide-plugin-interop-jvm/src/main/kotlin/org/spekframework/ide/console.kt +++ b/spek-ide-plugin-interop-jvm/src/main/kotlin/org/spekframework/ide/console.kt @@ -11,22 +11,27 @@ import kotlin.system.exitProcess class Spek2ConsoleLauncher { fun run(args: LauncherArgs) { - val paths = args.paths.map { - PathBuilder.parse(it) - .build() - } - val context = JvmDiscoveryContextFactory.create(args.sourceDirs.toList()) - val discoveryRequest = DiscoveryRequest(context, paths) + try { + val paths = args.paths.map { + PathBuilder.parse(it) + .build() + } + val context = JvmDiscoveryContextFactory.create(args.sourceDirs.toList()) + val discoveryRequest = DiscoveryRequest(context, paths) - val runtime = SpekRuntime() + val runtime = SpekRuntime() - val discoveryResult = runtime.discover(discoveryRequest) - val executionRequest = ExecutionRequest(discoveryResult.roots, ServiceMessageAdapter()) - runtime.execute(executionRequest) - // forces the jvm to shutdown even if there are non-daemon threads running. - // Ideally libraries should not leave non-daemon threads running after exit, unfortunately, - // this is quite common even with newer libraries. - exitProcess(0) + val discoveryResult = runtime.discover(discoveryRequest) + val executionRequest = ExecutionRequest(discoveryResult.roots, ServiceMessageAdapter()) + runtime.execute(executionRequest) + // forces the jvm to shutdown even if there are non-daemon threads running. + // Ideally libraries should not leave non-daemon threads running after exit, unfortunately, + // this is quite common even with newer libraries. + exitProcess(0) + } catch (e: Throwable) { + println("An internal error has occurred.") + e.printStackTrace() + } } }