How to miminise $response->{content} of the 500 error page?
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
Здраствуй! 2014-03-02 20:05 GMT+02:00 Иван Бессарабов <ivan@bessarabov.ru>:
Here is my problem.
If I understand your problem correctly, the main problem is in configuration. By default testing uses development environment and there is set "show_errrors = 1". That causes on die (or croak) to show full stack tree. Setting "show_errrors = 0" should give you simple 500 page. Also, there is Dancer::Exceptions and this gives us special keyword "raise". Maybe it is better to use it? I read about it here: http://advent.perldancer.org/2011/6 Hope i got you right. -- Best regards, Всего хорошего, Kõike hääd, Gunnar
Thank you for your answer! Unfortunately, this is not the solution. This is what I get when `show_errors = 1`: https://gist.github.com/bessarabov/9318850 (You see, there is the string `Error message at ` — I need this information). And this is what I get when `show_errors = 0`: https://gist.github.com/bessarabov/9318862 — in the test output there is no info that I need. Actually I did what I wanted by writing small sub that do what I need: https://github.com/bessarabov/DancerTestProblem/commit/593096f2e7b837a48f228... But I'm not sure that it is the best possible solution. And thank you for the Dancer::Exceptions I haven't knew that such thing is integrated into Dancer, but this does not solve my problem =) On Sun, Mar 2, 2014 at 11:46 PM, WK <wanradt@gmail.com> wrote:
Здраствуй!
2014-03-02 20:05 GMT+02:00 Иван Бессарабов <ivan@bessarabov.ru>:
Here is my problem.
If I understand your problem correctly, the main problem is in configuration.
By default testing uses development environment and there is set "show_errrors = 1". That causes on die (or croak) to show full stack tree. Setting "show_errrors = 0" should give you simple 500 page.
Also, there is Dancer::Exceptions and this gives us special keyword "raise". Maybe it is better to use it? I read about it here: http://advent.perldancer.org/2011/6
Hope i got you right.
-- Best regards, Всего хорошего, Kõike hääd,
Gunnar
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
participants (2)
-
WK -
Иван Бессарабов