MCPcopy Create free account
hub / github.com/SqliteModernCpp/sqlite_modern_cpp / main

Function main

tests/error_log2.cc:12–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10
11
12int main() {
13 bool error_detected = false;
14 error_log(
15 [&](errors::constraint e) {
16 cerr << e.get_code() << '/' << e.get_extended_code() << ": " << e.what() << endl;
17 error_detected = true;
18 }
19 );
20 database db(":memory:");
21 db << "CREATE TABLE person (id integer primary key not null, name TEXT);";
22
23 try {
24 db << "INSERT INTO person (id,name) VALUES (?,?)" << 1 << "jack";
25 // inserting again to produce error
26 db << "INSERT INTO person (id,name) VALUES (?,?)" << 1 << "jack";
27 } catch (errors::constraint& e) {
28 }
29
30 if(!error_detected) {
31 exit(EXIT_FAILURE);
32 }
33
34 exit(EXIT_SUCCESS);
35}

Callers

nothing calls this directly

Calls 3

error_logFunction · 0.85
get_codeMethod · 0.80
get_extended_codeMethod · 0.80

Tested by

no test coverage detected