Grinnz / Mojo-SQLite

Mojo::SQLite - A tiny Mojolicious wrapper for SQLite
https://metacpan.org/pod/Mojo::SQLite
Other
27 stars 12 forks source link

Actual error context information #6

Closed avkhozov closed 7 years ago

avkhozov commented 8 years ago

Issue like this https://github.com/kraih/mojo-pg/issues/20

Does this solution https://github.com/kraih/mojo-pg/commit/7a710adf27da6c7b4ec157d557c42cdb088e4813 actual for Mojo::SQLite?

Grinnz commented 8 years ago

Is there an issue you're having? Query errors are already croaked https://github.com/Grinnz/Mojo-SQLite/blob/master/lib/Mojo/SQLite/Database.pm#L113

avkhozov commented 8 years ago

Hmm, its work in simple scripts, but doesn't in mojolicious context:

#!/usr/bin/perl

use Mojolicious::Lite;
use Mojo::SQLite;

use Test::Mojo;
use Test::More;

my $s = Mojo::SQLite->new('file:///home/and/test.db?mode=rwc');

get '/' => sub {
  $s->db->query('select * from test');
  shift->render(text => 'ok');
};

my $t = Test::Mojo->new;
$t->get_ok('/')->status_is(200);

done_testing;

And output:

$ prove -lv sqlite.pl 
sqlite.pl .. [Mon Aug 22 10:58:06 2016] [debug] GET "/"
[Mon Aug 22 10:58:06 2016] [debug] Routing to a callback
[Mon Aug 22 10:58:06 2016] [error] DBD::SQLite::db prepare_cached failed: no such table: test at /usr/local/share/perl/5.22.1/Mojo/SQLite/Database.pm line 103.

[Mon Aug 22 10:58:06 2016] [debug] Template "exception.development.html.ep" not found
[Mon Aug 22 10:58:06 2016] [debug] Template "exception.html.ep" not found
[Mon Aug 22 10:58:06 2016] [debug] Rendering template "mojo/debug.html.ep"
[Mon Aug 22 10:58:06 2016] [debug] Rendering template "mojo/menubar.html.ep"
[Mon Aug 22 10:58:06 2016] [debug] Your secret passphrase needs to be changed
[Mon Aug 22 10:58:06 2016] [debug] 500 Internal Server Error (0.023959s, 41.738/s)

ok 1 - GET /
not ok 2 - 200 OK

#   Failed test '200 OK'
#   at sqlite.pl line 17.
#          got: '500'
#     expected: '200'
1..2
# Looks like you failed 1 test of 2.
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/2 subtests 

Test Summary Report
-------------------
sqlite.pl (Wstat: 256 Tests: 2 Failed: 1)
  Failed test:  2
  Non-zero exit status: 1
Files=1, Tests=2,  0 wallclock secs ( 0.03 usr  0.00 sys +  0.34 cusr  0.00 csys =  0.37 CPU)
Result: FAIL
Grinnz commented 7 years ago

This should be improved in 1.002. Please reopen if you have any further issue.

avkhozov commented 7 years ago

Thanks!