2010-06-01 14:38:56 +02:00
|
|
|
/* sbt -- Simple Build Tool
|
|
|
|
|
* Copyright 2010 Mark Harrah
|
|
|
|
|
*/
|
2010-05-31 03:14:18 +02:00
|
|
|
package sbt
|
|
|
|
|
|
2010-06-07 14:53:21 +02:00
|
|
|
import Incomplete.{Error, Value => IValue}
|
|
|
|
|
final case class Incomplete(tpe: IValue = Error, message: Option[String] = None, causes: Seq[Incomplete] = Nil, directCause: Option[Throwable] = None)
|
|
|
|
|
extends Exception(message.orNull, directCause.orNull)
|
|
|
|
|
|
|
|
|
|
object Incomplete extends Enumeration {
|
|
|
|
|
val Skipped, Error = Value
|
2010-06-10 14:16:39 +02:00
|
|
|
def show(i: Incomplete, traces: Boolean): String =
|
|
|
|
|
{
|
|
|
|
|
val exceptions = allExceptions(i)
|
2010-09-13 04:41:02 +02:00
|
|
|
val traces = exceptions.map(ex => ex.getStackTrace.mkString(ex.toString + "\n\t", "\n\t", "\n"))
|
2010-06-10 14:16:39 +02:00
|
|
|
val causeStr = if(i.causes.isEmpty) "" else (i.causes.length + " cause(s)")
|
|
|
|
|
"Incomplete (" + show(i.tpe) + ") " + i.message.getOrElse("") + causeStr + "\n" + traces
|
|
|
|
|
}
|
2010-10-23 22:34:22 +02:00
|
|
|
|
|
|
|
|
def allExceptions(is: Seq[Incomplete]): Iterable[Throwable] =
|
|
|
|
|
allExceptions(new Incomplete(causes = is))
|
2010-06-10 14:16:39 +02:00
|
|
|
def allExceptions(i: Incomplete): Iterable[Throwable] =
|
|
|
|
|
{
|
|
|
|
|
val exceptions = IDSet.create[Throwable]
|
|
|
|
|
val visited = IDSet.create[Incomplete]
|
|
|
|
|
def visit(inc: Incomplete): Unit =
|
|
|
|
|
visited.process(inc)( () ) {
|
|
|
|
|
exceptions ++= inc.directCause.toList
|
|
|
|
|
inc.causes.foreach(visit)
|
|
|
|
|
}
|
|
|
|
|
visit(i)
|
|
|
|
|
exceptions.all
|
|
|
|
|
}
|
|
|
|
|
def show(tpe: Value) = tpe match { case Skipped=> "skipped"; case Error => "error" }
|
2010-06-07 14:53:21 +02:00
|
|
|
}
|