Files
sbt/main/command/ExceptionCategory.scala
T
Mark Harrah 5ff33fad3e Second try at printing message when stack trace suppressed.
Problems:

  1. Without a message, users don't find 'last'
  2. Showing a message for every error clutters output.

This tries to address these issues by:

1. Only showing the message when other feedback has not been provided and
   'last' would not usually be helpful.  This will require ongoing tweaking.
   For now, all commands except 'compile' display the message.  'update' could
   omit the message as well, but perhaps knowing about 'last' might be
   useful there.

2. Including the exact command to show the output:
    last test:compile
   and not just
    last <task>

3. Highlighting the command in blue for visibility as an experiment.

Review by @ijuma and @retronym, please.
2012-05-19 18:20:19 -04:00

26 lines
824 B
Scala

package sbt
import java.lang.reflect.InvocationTargetException
import scala.annotation.tailrec
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
}
}