mirror of https://github.com/sbt/sbt.git
wideConvert lets the serious errors pass through, use it in Execute
This commit is contained in:
parent
93492a011c
commit
1584f01de8
|
|
@ -7,10 +7,17 @@ object ErrorHandling
|
|||
{
|
||||
def translate[T](msg: => String)(f: => T) =
|
||||
try { f }
|
||||
catch { case e => throw new TranslatedException(msg + e.toString, e) }
|
||||
catch { case e: Exception => throw new TranslatedException(msg + e.toString, e) }
|
||||
|
||||
def wideConvert[T](f: => T): Either[Throwable, T] =
|
||||
try { Right(f) }
|
||||
catch { case e => Left(e) } // TODO: restrict type of e
|
||||
catch
|
||||
{
|
||||
case ex @ (_: Exception | _: StackOverflowError) => Left(ex)
|
||||
case err @ (_: ThreadDeath | _: VirtualMachineError) => throw err
|
||||
case x => Left(x)
|
||||
}
|
||||
|
||||
def convert[T](f: => T): Either[Exception, T] =
|
||||
try { Right(f) }
|
||||
catch { case e: Exception => Left(e) }
|
||||
|
|
|
|||
Loading…
Reference in New Issue