minor: Fix and relax error handling on script template loading

This commit is contained in:
Ilya Chernikov
2016-09-23 13:29:28 +02:00
parent 759f6f3ded
commit 6da7276510
@@ -100,15 +100,26 @@ open class KotlinScriptDefinitionFromAnnotatedTemplate(
} }
.map { it.getProxy(classLoader) } .map { it.getProxy(classLoader) }
}) })
fun logClassloadingError(ex: Throwable) {
logScriptDefMessage(ScriptDependenciesResolver.ReportSeverity.WARNING, ex.message ?: "Invalid script template: ${template.qualifiedName}", null)
}
try { try {
val fileDeps = resolver?.resolve(script, environment, ::logScriptDefMessage, previousDependencies) val fileDeps = resolver?.resolve(script, environment, ::logScriptDefMessage, previousDependencies)
// TODO: use it as a Future // TODO: use it as a Future
return fileDeps?.get() return fileDeps?.get()
} }
catch (ex: ClassCastException) { catch (ex: ClassNotFoundException) {
logScriptDefMessage(ScriptDependenciesResolver.ReportSeverity.ERROR, ex.message ?: "Invalid script template: ${template.qualifiedName}", null) logClassloadingError(ex)
return null
} }
catch (ex: NoClassDefFoundError) {
logClassloadingError(ex)
}
catch (ex: ClassCastException) {
logClassloadingError(ex)
}
return null
} }
private fun <TF> getAnnotationEntries(file: TF, project: Project): Iterable<KtAnnotationEntry> = when (file) { private fun <TF> getAnnotationEntries(file: TF, project: Project): Iterable<KtAnnotationEntry> = when (file) {