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

Function main

tests/error_log.cc:12–38  ·  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) {
16 cerr << "Wrong error detected!" << endl;
17 },
18 [&](errors::constraint_primarykey e) {
19 cerr << e.get_code() << '/' << e.get_extended_code() << ": " << e.what() << endl;
20 error_detected = true;
21 }
22 );
23 database db(":memory:");
24 db << "CREATE TABLE person (id integer primary key not null, name TEXT);";
25
26 try {
27 db << "INSERT INTO person (id,name) VALUES (?,?)" << 1 << "jack";
28 // inserting again to produce error
29 db << "INSERT INTO person (id,name) VALUES (?,?)" << 1 << "jack";
30 } catch (errors::constraint& e) {
31 }
32
33 if(!error_detected) {
34 exit(EXIT_FAILURE);
35 }
36
37 exit(EXIT_SUCCESS);
38}

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