Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions core/common/src/main/scala/net/liftweb/common/Box.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,9 @@ final class ParamFailure[T](override val msg: String,
case null => 0
case x => x.hashCode()
})

override def ~>[T](errorCode: => T): ParamFailure[T] =
ParamFailure(msg, exception, Full(this), errorCode)
}

/**
Expand Down
12 changes: 12 additions & 0 deletions core/common/src/test/scala/net/liftweb/common/BoxSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,9 @@ class BoxSpec extends Specification with ScalaCheck with BoxGenerator {
Full(new Exception("broken")),
Full(Failure("nested cause", Empty, Empty))).chain must_== Full(Failure("nested cause", Empty, Empty))
}
"be converted to a ParamFailure" in {
Failure("hi mom") ~> 404 must_== ParamFailure("hi mom", Empty, Empty, 404)
}
}

"A Failure is an Empty Box which" should {
Expand All @@ -322,6 +325,15 @@ class BoxSpec extends Specification with ScalaCheck with BoxGenerator {
}
}

"A ParamFailure is a failure which" should {
"appear in the chain when ~> is invoked on it" in {
Failure("Apple") ~> 404 ~> "apple" must_==
ParamFailure("Apple", Empty, Full(
ParamFailure("Apple", Empty, Empty, 404)
), "apple")
}
}

"A Box equals method" should {

"return true with comparing two identical Box messages" in check {
Expand Down