diff options
author | Tobias Roeser <le.petit.fou@web.de> | 2018-12-20 13:20:37 +0100 |
---|---|---|
committer | Tobias Roeser <le.petit.fou@web.de> | 2018-12-20 13:22:36 +0100 |
commit | 9fdf875cebcb4b078afbb198870cdc356d2b9a04 (patch) | |
tree | f04b7441faebfa257242a3f9609fbca8e1db5d3d /main/api/src | |
parent | 350a9a6bb0e6459df3f677e7f1a95a07e772b1b8 (diff) | |
download | mill-9fdf875cebcb4b078afbb198870cdc356d2b9a04.tar.gz mill-9fdf875cebcb4b078afbb198870cdc356d2b9a04.tar.bz2 mill-9fdf875cebcb4b078afbb198870cdc356d2b9a04.zip |
Detailed the difference between Failure and Exception
Diffstat (limited to 'main/api/src')
-rw-r--r-- | main/api/src/mill/api/Result.scala | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/main/api/src/mill/api/Result.scala b/main/api/src/mill/api/Result.scala index c1aa5c5c..f6579abd 100644 --- a/main/api/src/mill/api/Result.scala +++ b/main/api/src/mill/api/Result.scala @@ -39,18 +39,26 @@ object Result { sealed trait Failing[+T] extends Result[T] { def map[V](f: T => V): Failing[V] } + + /** + * An intensional failure, which provides a proper error message as well as an optional result value. + * @param msg The error message. + * @param value The optional result value. + * @tparam T The result type of the computed task. + */ case class Failure[T](msg: String, value: Option[T] = None) extends Failing[T] { def map[V](f: T => V) = Result.Failure(msg, value.map(f(_))) } /** - * A failed task which failed with a concrete exception. + * An (mostly) unintentionally failed task which the exception that caused the failure. * @param throwable The exception that describes or caused the failure. * @param outerStack The [[OuterStack]] of the failed task. */ case class Exception(throwable: Throwable, outerStack: OuterStack) extends Failing[Nothing] { def map[V](f: Nothing => V) = this } + class OuterStack(val value: Seq[StackTraceElement]) { override def hashCode() = value.hashCode() |