minor: Fix and relax error handling on script template loading
This commit is contained in:
+14
-3
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user