@@ -102,7 +102,7 @@ object MaybeEither {
102
102
def apply [A ](x : => A ): MaybeEither [A ] = Maybe (x) match {
103
103
case j@ Just (_) =>
104
104
j
105
- case f@ Failed (_,_ ) =>
105
+ case f@ Failed (_) =>
106
106
f
107
107
case NoVal =>
108
108
Failed (new Exception (" Got NoVal for a MaybeFailed" ))
@@ -132,11 +132,9 @@ object Maybe {
132
132
case _ => Just (value)
133
133
}
134
134
} catch {
135
- case e : Throwable => Failed (e, " Maybe.apply() " )
135
+ case e : Throwable => Failed (e)
136
136
}
137
137
}
138
-
139
- def failed (exception : Throwable , fmt : String , args : Any * ) = Failed (exception, fmt.format(args : _* ))
140
138
}
141
139
142
140
final case class Just [@ specialized + A ](get : A ) extends MaybeOption [A ] with MaybeEither [A ] {
@@ -202,11 +200,9 @@ case object NoVal extends MaybeOption[Nothing] {
202
200
/**
203
201
* A Maybe wrapper for an exception.
204
202
*/
205
- final case class Failed (exception : Throwable , explanation : String = " " ) extends MaybeEither [Nothing ] {
206
- require(exception ne null , " Exception is null" )
207
- require(explanation ne null , " Explanation is null" )
203
+ final case class Failed (cause : Throwable ) extends MaybeEither [Nothing ] {
204
+ require(cause ne null , " cause is null" )
208
205
209
- def this (exception : Throwable , fmt : String , args : Any * ) = this (exception, fmt.format(args))
210
206
def isJust = false
211
207
def isNoVal = false
212
208
def isFailed = true
@@ -233,15 +229,9 @@ final case class Failed(exception: Throwable, explanation: String = "") extends
233
229
def flatten1 [U ](implicit ev : <:< [Nothing , Maybe [U ]]) = this
234
230
235
231
def detailedMessage : String = {
236
- if (explanation.trim.length > 0 ) {
237
- " %s:[%s] %s" .format(explanation, exception.getClass.getName, exception.getMessage)
238
- } else {
239
- " [%s] %s" .format(exception.getClass.getName, exception.getMessage)
240
- }
232
+ " [%s] %s" .format(cause.getClass.getName, cause.getMessage)
241
233
}
242
234
243
235
override def equals (that : Any ) =
244
- that.isInstanceOf [Failed ] &&
245
- that.asInstanceOf [Failed ].exception == this .exception &&
246
- that.asInstanceOf [Failed ].explanation == this .explanation
236
+ that.isInstanceOf [Failed ] && that.asInstanceOf [Failed ].cause == this .cause
247
237
}
0 commit comments