From bb8dd21620d9a8a35c6d1a4a4070d5279e1c2950 Mon Sep 17 00:00:00 2001 From: Grzegorz Kossakowski Date: Mon, 27 Jan 2014 19:48:13 +0100 Subject: [PATCH] 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). --- .../main/scala/sbt/compiler/IncrementalCompiler.scala | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/compile/integration/src/main/scala/sbt/compiler/IncrementalCompiler.scala b/compile/integration/src/main/scala/sbt/compiler/IncrementalCompiler.scala index 68ad63f2c..5028c7996 100644 --- a/compile/integration/src/main/scala/sbt/compiler/IncrementalCompiler.scala +++ b/compile/integration/src/main/scala/sbt/compiler/IncrementalCompiler.scala @@ -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) + } + } }