The $sth->execute() is throwing an exception that causes the script to stop
executing and never hits your die statement.

In my admittedly limited database experience, I use the Try::Tiny module to
handle these situations.

So for your snippet, I would add "use Try::Tiny;" to the module, and use
something like this...

my $exception;
try
{
  $sth->execute();
}
catch
{
  $exception = $_;
}; ## Do not forget this trailing semi-colon after the closing bracket

die "SQL execute error: [$dbh->errstr], caller: [$caller]" if ($exception);



On Thu, Aug 21, 2014 at 10:13 AM, Neil Watson <[email protected]> wrote:

> Greetings,
>
> I'm not able to see the output a die statement.  I don't know if this is
> a Mojo quirk or my own Perl ignorance. If I have this in a test case:
>
> lives_ok
> {
>   $t->get_ok('/')
>   ->status_is(200, 'Load /home' )
>   ->content_like( qr/ .... /, 'Test content );
> } 'get / home page';
>
> Somewhere in the code is have:
>
> $sth->execute( $param_list )
>    or die "SQL execute error: [$dbh->errstr], caller: [$caller]";
>
> Testing from app.pl test, in the normal Mojo fashion, shows a failed test
> at the execute line, but the die statement is not visible. Instead I get
>
> DBD::Pg::st execute failed: called with 1 bind variables when 2 are
> needed at lib/DeltaR/Query.pm line 51.
>
> and then the typical Mojo test server error page. Nowhere do I see the
> die statement's output. What have I missed?
>
> --
> Neil Watson
> Linux/UNIX Consultant
> http://watson-wilson.ca
>
> --
> You received this message because you are subscribed to the Google Groups
> "Mojolicious" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/mojolicious.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to