Skip to content
Browse files

preserve IOException type when translating exceptions. fixes #253

  • Loading branch information...
1 parent 76398a5 commit 4afbc5b1b4c19011110a0649e2c3d062061f9dd9 @harrah committed Nov 4, 2011
Showing with 7 additions and 3 deletions.
  1. +7 −3 util/control/ErrorHandling.scala
View
10 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
-}
+}
+final class TranslatedIOException private[sbt](msg: String, cause: IOException) extends TranslatedException(msg, cause)

0 comments on commit 4afbc5b

Please sign in to comment.
Something went wrong with that request. Please try again.