Merge pull request #5411 from eatkins/layering-error-message

Improve ClassLoader layering error message
This commit is contained in:
eugene yokota 2020-02-02 15:14:38 -05:00 committed by GitHub
commit f669fc734a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 1 deletions

View File

@ -78,7 +78,22 @@ class Run(private[sbt] val newLoader: Seq[File] => ClassLoader, trapExit: Boolea
val main = getMainMethod(mainClass, loader)
invokeMain(loader, main, options)
} catch {
case e: java.lang.reflect.InvocationTargetException => throw e.getCause
case e: java.lang.reflect.InvocationTargetException =>
e.getCause match {
case ex: ClassNotFoundException =>
val className = ex.getMessage
try {
loader.loadClass(className)
val msg =
s"$className is on the project classpath but not visible to the ClassLoader " +
"that attempted to load it.\n" +
"See https://www.scala-sbt.org/1.x/docs/In-Process-Classloaders.html for " +
"further information."
log.error(msg)
} catch { case NonFatal(_) => }
throw ex
case ex => throw ex
}
}
def directExecute(): Try[Unit] =
Try(execute()) recover {