[Dancer-users] Dancer::Test and negative testing, error reporting

Naveed Massjouni naveedm9 at gmail.com
Mon Mar 7 05:35:46 CET 2011


On Sat, Mar 5, 2011 at 7:44 PM, Rudolf Muehlbauer
<rudolf.muehlbauer at gmail.com> wrote:
> Dear List,
>
>
> I casually use `die` inside my handlers to report errors.
> This works ok when i use the application with the browser.
>
> The `die`s are translated to HTTP 500, the error is reported to the
> user.
>
> Now my problem:
> I want to test corner-cases in my Dancer::Test cases. But in the
> test-cases, my `die`s are not translated to HTTP 500, instead the test
> dies "Dubiously".
>
> Is there a way to get Dancer::Test to behave like Dancer w/o Test?
> I really don't want to `eval` all my tests - set aside that this would
> also not allow me to test for HTTP 500.
>
> Alternatively, how should error reporting happen without `die`? I miss
> my structured exception handling...

Inside of your routes, you can return a 500 error response:
    get '/test500' => sub { return error 'oops' };
-Naveed

>
> Any help greatly appreciated,
>
> --
> Rudolf Muehlbauer <rudolf.muehlbauer at gmail.com>
>
> _______________________________________________
> Dancer-users mailing list
> Dancer-users at perldancer.org
> http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
>
>


More information about the Dancer-users mailing list