apply formatting

This commit is contained in:
Eugene Yokota
2019-04-20 23:23:13 -04:00
parent 2ac7501c7c
commit 98ec0075f4
9 changed files with 105 additions and 67 deletions
@@ -7,20 +7,26 @@ import java.io.IOException
object ErrorHandling {
def translate[T](msg: => String)(f: => T) =
try { f } catch {
try {
f
} 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) } catch {
try {
Right(f)
} catch {
case ex @ (_: Exception | _: StackOverflowError) => Left(ex)
case err @ (_: ThreadDeath | _: VirtualMachineError) => throw err
case x: Throwable => Left(x)
}
def convert[T](f: => T): Either[Exception, T] =
try { Right(f) } catch { case e: Exception => Left(e) }
try {
Right(f)
} catch { case e: Exception => Left(e) }
def reducedToString(e: Throwable): String =
if (e.getClass == classOf[RuntimeException]) {