From 30bdcf68d43fc05dcc8c2e975a4ba1880a82bf0f Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Fri, 4 Nov 2011 13:11:10 -0400 Subject: [PATCH] preserve IOException type when translating exceptions. fixes #253 --- util/control/ErrorHandling.scala | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/util/control/ErrorHandling.scala b/util/control/ErrorHandling.scala index a346e0d14..caf653da1 100644 --- a/util/control/ErrorHandling.scala +++ b/util/control/ErrorHandling.scala @@ -7,7 +7,10 @@ object ErrorHandling { def translate[T](msg: => String)(f: => T) = try { f } - catch { case e: Exception => throw new TranslatedException(msg + e.toString, e) } + catch { + case e: IOException => throw new TranslatedIOException(msg + e.toString, e) + case e: Exception => throw new TranslatedException(msg + e.toString, e) + } def wideConvert[T](f: => T): Either[Throwable, T] = try { Right(f) } @@ -31,7 +34,8 @@ object ErrorHandling else e.toString } -final class TranslatedException private[sbt](msg: String, cause: Throwable) extends RuntimeException(msg, cause) +sealed class TranslatedException private[sbt](msg: String, cause: Throwable) extends RuntimeException(msg, cause) { override def toString = msg -} \ No newline at end of file +} +final class TranslatedIOException private[sbt](msg: String, cause: IOException) extends TranslatedException(msg, cause)