Record the name of an Analysis file in case of a read failure.

Catch ReadException and wrap it in IOException that carries the name
of the file we failed to read in its message.

We have to catch exception and wrap them because in TextAnalysisFormat
we don't have an access to the file name (it operates using an abstract
reader).
This commit is contained in:
Grzegorz Kossakowski 2014-01-27 19:48:13 +01:00
parent 668ae8d8b1
commit bb8dd21620
1 changed files with 8 additions and 1 deletions

View File

@ -46,5 +46,12 @@ object IC extends IncrementalCompiler[Analysis, AnalyzingCompiler]
}
def readCacheUncaught(file: File): (Analysis, CompileSetup) =
Using.fileReader(IO.utf8)(file) { reader => TextAnalysisFormat.read(reader) }
Using.fileReader(IO.utf8)(file) { reader =>
try {
TextAnalysisFormat.read(reader)
} catch {
case ex: sbt.inc.ReadException =>
throw new java.io.IOException(s"Error while reading $file", ex)
}
}
}