sbt.ExceptionCategory.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of command_2.12 Show documentation
Show all versions of command_2.12 Show documentation
sbt is an interactive build tool
The newest version!
/*
* sbt
* Copyright 2023, Scala center
* Copyright 2011 - 2022, Lightbend, Inc.
* Copyright 2008 - 2010, Mark Harrah
* Licensed under Apache License 2.0 (see LICENSE)
*/
package sbt
import java.lang.reflect.InvocationTargetException
import scala.annotation.tailrec
import sbt.internal.util.{ AlreadyHandledException, MessageOnlyException, UnprintableException }
private[sbt] sealed abstract class ExceptionCategory {
def isFull: Boolean = false
}
private[sbt] object ExceptionCategory {
@tailrec def apply(t: Throwable): ExceptionCategory = t match {
case _: AlreadyHandledException | _: UnprintableException => AlreadyHandled
case ite: InvocationTargetException =>
val cause = ite.getCause
if (cause == null || cause == ite) new Full(ite) else apply(cause)
case _: MessageOnlyException => new MessageOnly(t.toString)
case _ => new Full(t)
}
object AlreadyHandled extends ExceptionCategory
final class MessageOnly(val message: String) extends ExceptionCategory
final class Full(val exception: Throwable) extends ExceptionCategory {
override def isFull = true
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy