diff options
author | Paul Phillips <paulp@improving.org> | 2009-04-28 21:53:29 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2009-04-28 21:53:29 +0000 |
commit | 6029fa793184426e4cc9e81fddcd5acee902311d (patch) | |
tree | d4824dc4920e34427ca5d853dcf2eaf43d4b05ff /src/compiler | |
parent | 6875e2fde566b0ced981fb092480827778483f1e (diff) | |
download | scala-6029fa793184426e4cc9e81fddcd5acee902311d.tar.gz scala-6029fa793184426e4cc9e81fddcd5acee902311d.tar.bz2 scala-6029fa793184426e4cc9e81fddcd5acee902311d.zip |
Added a MissingRequirementError variant of Fata...
Added a MissingRequirementError variant of FatalError so as to
improve the amazingly confusing "class file is broken" message which
people get whenever they are missing a dependency. Before: class file
'jdo2-api-2.3-SNAPSHOT.jar(javax/jdo/Transaction.class)' is broken
After: Missing dependency 'class javax.transaction.Synchronization',
required by jdo2-api-2.3-SNAPSHOT.jar(javax/jdo/Transaction.class)
Diffstat (limited to 'src/compiler')
3 files changed, 13 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/FatalError.scala b/src/compiler/scala/tools/nsc/FatalError.scala index 9d219410e2..836bd79175 100644 --- a/src/compiler/scala/tools/nsc/FatalError.scala +++ b/src/compiler/scala/tools/nsc/FatalError.scala @@ -7,3 +7,10 @@ package scala.tools.nsc case class FatalError(msg: String) extends Exception(msg) +class MissingRequirementError(val req: String) extends FatalError(req + " not found.") +object MissingRequirementError { + def unapply(x: Throwable) = x match { + case x: MissingRequirementError => Some(x.req) + case _ => None + } +} diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala index f16a7d2716..559f3f5890 100644 --- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala +++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala @@ -399,7 +399,7 @@ trait Definitions { if (result == NoSymbol) { if (settings.debug.value) { Console.println(sym.info); Console.println(sym.info.members) }//debug - throw new FatalError((if (module) "object " else "class ") + fullname + " not found.") + throw new MissingRequirementError((if (module) "object " else "class ") + fullname) } result } diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala index 426a9d4a52..a4dcdc8fee 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala @@ -51,6 +51,9 @@ abstract class ClassfileParser { } def parse(file: AbstractFile, root: Symbol) = try { + def handleMissing(e: MissingRequirementError) = + throw new IOException("Missing dependency '" + e.req + "', required by " + in.file) + def handleError(e: Exception) = { if (settings.debug.value) e.printStackTrace() throw new IOException("class file '" + in.file + "' is broken\n(" + { @@ -84,8 +87,8 @@ abstract class ClassfileParser { this.pool = new ConstantPool parseClass() } catch { - case e: FatalError => handleError(e) - case e: RuntimeException => handleError(e) + case e: MissingRequirementError => handleMissing(e) + case e: RuntimeException => handleError(e) } } finally { busy = false |