Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Actual error context information #6

Closed
avkhozov opened this issue Aug 22, 2016 · 4 comments
Closed

Actual error context information #6

avkhozov opened this issue Aug 22, 2016 · 4 comments

Comments

@avkhozov
Copy link

Issue like this mojolicious/mojo-pg#20

Does this solution mojolicious/mojo-pg@7a710ad actual for Mojo::SQLite?

@Grinnz
Copy link
Owner

Grinnz commented Aug 22, 2016

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
Copy link
Author

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 added a commit that referenced this issue Nov 30, 2016
  - Improved contextual caller information in query error messages. (#6)
  - Fix memory leak when reusing the same database handle many times. (#7)
@Grinnz
Copy link
Owner

Grinnz commented Nov 30, 2016

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

@Grinnz Grinnz closed this as completed Nov 30, 2016
@avkhozov
Copy link
Author

avkhozov commented Dec 1, 2016

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants