[dancer-users] How to miminise $response->{content} of the 500 error page?

Иван Бессарабов ivan at bessarabov.ru
Sun Mar 2 18:05:42 GMT 2014


Here is my problem.

I'm writing a small Dancer1 app. I'm writing tests to simplify the
development. In my code I use a lot of `croak` to die in any unusual
situation. Everything works fine, but I have one small thing I hope can be
done better. (Actually everyting is working, but I want to make the
development a bit more better)

My problem is with the test output.

In my test I create Dancer::Response object:

    my $response = dancer_response( GET => '/die' );

and then test if `$response->{content}` contains needed text.

In case the `croak` is executed the `$response->{content}` contaings huge
html page with 500 error. So, here is what I see when I run the test:

https://upload.bessarabov.ru/bessarabov/djXe9Nlm_EnI_TCnPn8sRQjFxKY.png

Well, that output contains the error message that I need, but it is in the
beginning of the content, and I need to scroll to that content to find out
what was the error message:

https://upload.bessarabov.ru/bessarabov/hyycVMgrmrC2x5yAbo0GHZt1lG4.png

I hope that there is some simple way to simplify the output of tests to make
it easier to develop.

I was thinking about the solution, the only think that I can imagine is to
made Dancer output my custom error page that has nothing but error message.
What do you think? Should I try to do this solution or there is some
other way to
show needed info in test outpur.

PS I've created a simple app that shows this problem:
https://github.com/bessarabov/DancerTestProblem


More information about the dancer-users mailing list