parent
0ebbaffe9b
commit
c034d20993
2 changed files with 9 additions and 2 deletions
|
|
@ -33,6 +33,13 @@ class StatusReplySpec extends AkkaSpec with ScalaFutures {
|
|||
case _ => fail()
|
||||
}
|
||||
}
|
||||
"not throw exception if null" in {
|
||||
(null: StatusReply[_]) match {
|
||||
case StatusReply.Success(_) => fail()
|
||||
case StatusReply.Error(_) => fail()
|
||||
case _ =>
|
||||
}
|
||||
}
|
||||
"pattern match error with text" in {
|
||||
StatusReply.Error("boho!") match {
|
||||
case StatusReply.Error(_) =>
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ object StatusReply {
|
|||
*/
|
||||
def apply[T](value: T): StatusReply[T] = new StatusReply(ScalaSuccess(value))
|
||||
def unapply(status: StatusReply[Any]): Option[Any] =
|
||||
if (status.isSuccess) Some(status.getValue)
|
||||
if (status != null && status.isSuccess) Some(status.getValue)
|
||||
else None
|
||||
}
|
||||
|
||||
|
|
@ -150,7 +150,7 @@ object StatusReply {
|
|||
*/
|
||||
def apply[T](exception: Throwable): StatusReply[T] = new StatusReply(ScalaFailure(exception))
|
||||
def unapply(status: StatusReply[_]): Option[Throwable] =
|
||||
if (status.isError) Some(status.getError)
|
||||
if (status != null && status.isError) Some(status.getError)
|
||||
else None
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue