Custom check failure messages?

I am trying to test to make sure that the application is not redirecting me to a particular page. I do that like this:

request // if Location redirect is present // ensure it is not the /security/not-eligible path .check( header("Location") .transformOption( extract => extract match { case None => Some(true) case Some(x) => Some( ! x.contains( "/security/not-eligible" ) ) }) .is( true ) )

When that happens, this is what I see in the logs:

Request ‘login’ failed: header(Location) transformOption.find(0).is(true), but actually found false


What I would really like to do is throw an error that says “Server redirected to /security/not-eligible”. Is that doable?

I’d actually like to be able to customize more than just this message, but I’m using this as an example.

Location header won’t be available by default, as followRedirect is enabled.
Then, there’s checks for this:

I’ve disabled followRedirect. And my check is working just fine. I just want to change the error message into something meaningful. Like I said, I’m using this as an example. What I’d like to see is something like:

.check( condition, failureMsg )

Not currently doable, but that wouldn’t be very hard to implement.
Feeling like contributing? :wink:


Sure. Any chance you could tell me where the extra parameter would need to be put?

In Check.

The thing is to decide the function signature: which input parameter? The default String message? The actual value?

What is the status of this issue? Is it implemented (rejected)?

Not implemented. Contributions welcome.


Sorry for bumping an old topic but I’m curious if this has been implemented yet (using 2.2.5)? If not would it be fine if I can take a stab at it?

Please do! I'm also looking for this feature for a while now :slight_smile: