diff options
author | Martin Odersky <odersky@gmail.com> | 2013-02-15 16:39:00 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-02-15 16:39:00 +0100 |
commit | ddb301187b471f002716e5c0ced98f3d4fae1781 (patch) | |
tree | 27a98c57e491daa53fd47a5f8d5c0a08b671cbb2 /src/dotty/tools/dotc/core/pickling/ClassfileParser.scala | |
parent | 5e219c1d8426da4fba6c4604e24f4bceb3573392 (diff) | |
download | dotty-ddb301187b471f002716e5c0ced98f3d4fae1781.tar.gz dotty-ddb301187b471f002716e5c0ced98f3d4fae1781.tar.bz2 dotty-ddb301187b471f002716e5c0ced98f3d4fae1781.zip |
Consolidating error handling in unpickler and classfileparser.
MissingRequirement eliminated; it got replaced by new StubSymbol handling.
Diffstat (limited to 'src/dotty/tools/dotc/core/pickling/ClassfileParser.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/pickling/ClassfileParser.scala | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala b/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala index 2ece39dbb..9e9ea6257 100644 --- a/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala +++ b/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala @@ -31,39 +31,28 @@ class ClassfileParser( protected var currentClassName: Name = _ // JVM name of the current class protected var classTParams = Map[Name,Symbol]() - protected var srcfile0 : Option[AbstractFile] = None //needs freshing out + protected var srcfile0 : Option[AbstractFile] = None //needs fleshing out def srcfile = srcfile0 private def currentIsTopLevel = !(classRoot.name contains '$') private val mk = makeTypedTree - private def handleMissing(e: MissingRequirementError) = { - if (settings.debug.value) e.printStackTrace - throw new IOException("Missing dependency '" + e.req + "', required by " + in.file) - } - private def handleError(e: Exception) = { - if (settings.debug.value) e.printStackTrace() - throw new IOException("class file '%s' is broken\n(%s/%s)".format( - in.file, - e.getClass, - if (e.getMessage eq null) "" else e.getMessage) - ) - } private def mismatchError(c: Symbol) = { throw new IOException("class file '%s' has location not matching its contents: contains ".format(in.file) + c) } - private def parseErrorHandler[T]: PartialFunction[Throwable, T] = { - case e: MissingRequirementError => handleMissing(e) - case e: RuntimeException => handleError(e) - } - - def run(): Unit = { + def run(): Unit = try { debuglog("[class] >> " + classRoot.fullName) parseHeader this.pool = new ConstantPool parseClass() + } catch { + case e: RuntimeException => + if (settings.debug.value) e.printStackTrace() + throw new IOException( + s"""class file $classfile is broken, reading aborted with a + |${e.getClass}/${Option(e.getMessage).getOrElse("")}""".stripMargin) } private def parseHeader() { |