sqlite - Beginner C++ - Trying to catch an exception -
so have code:
#include <iostream> using namespace std; #include "libsqlite.hpp" int main() { sqlite::sqlite db( "firefly.sqlite" ); auto cur = db.get_statement(); // cur->set_sql( "create table students_mark (sid int, name varchar(255), pt1_mark int, pt2_mark int, cw_mark int, primary key(sid, name));" ); cur->set_sql( "insert students_mark (sid, name, pt1_mark, pt2_mark, cw_mark) values (?, ?, ?, ?, ?);" ); cur->prepare(); }
which gives me error:
libc++abi.dylib: terminating uncaught exception of type sqlite::exception: std::exception abort trap: 6
so tried catch exception understand better, can't seem archieve goal.
here's did:
try { cur->prepare(); } catch(exception& e) { cout << "error: " << e.what() << endl; }
and gives me output: error: std::exception
what can do?
thanks lot
exceptions exist several reasons. right it's there let know somethings wrong. catching won't solve issue itself. change behaviour of program after problem occurred.
you caught exception fine using catch (sqlite::exception &e)
, know issue. now, research , fix exception telling you.
Comments
Post a Comment