Replace abort() by return EXIT_FAILURE

This commit is contained in:
Sébastien Rombauts 2013-09-03 10:30:36 +02:00
parent 7d775e67c8
commit 5b6170dfa1

View File

@ -126,7 +126,7 @@ int main (void)
catch (std::exception& e) catch (std::exception& e)
{ {
std::cout << "SQLite exception: " << e.what() << std::endl; std::cout << "SQLite exception: " << e.what() << std::endl;
abort(); // unexpected error : abort the example program return EXIT_FAILURE; // unexpected error : exit the example program
} }
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
@ -144,7 +144,7 @@ int main (void)
catch (std::exception& e) catch (std::exception& e)
{ {
std::cout << "SQLite exception: " << e.what() << std::endl; std::cout << "SQLite exception: " << e.what() << std::endl;
abort(); // unexpected error : abort the example program return EXIT_FAILURE; // unexpected error : exit the example program
} }
// The execAndGet wrapper example (3/6) : // The execAndGet wrapper example (3/6) :
@ -163,7 +163,7 @@ int main (void)
catch (std::exception& e) catch (std::exception& e)
{ {
std::cout << "SQLite exception: " << e.what() << std::endl; std::cout << "SQLite exception: " << e.what() << std::endl;
abort(); // unexpected error : abort the example program return EXIT_FAILURE; // unexpected error : exit the example program
} }
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
@ -203,7 +203,7 @@ int main (void)
catch (std::exception& e) catch (std::exception& e)
{ {
std::cout << "SQLite exception: " << e.what() << std::endl; std::cout << "SQLite exception: " << e.what() << std::endl;
abort(); // unexpected error : abort the example program return EXIT_FAILURE; // unexpected error : exit the example program
} }
remove("test.db3"); remove("test.db3");
@ -234,7 +234,7 @@ int main (void)
catch (std::exception& e) catch (std::exception& e)
{ {
std::cout << "SQLite exception: " << e.what() << std::endl; std::cout << "SQLite exception: " << e.what() << std::endl;
abort(); // unexpected error : abort the example program return EXIT_FAILURE; // unexpected error : exit the example program
} }
// Exemple of a rollbacked transaction : // Exemple of a rollbacked transaction :
@ -249,7 +249,7 @@ int main (void)
nb = db.exec("INSERT INTO test ObviousError"); nb = db.exec("INSERT INTO test ObviousError");
std::cout << "INSERT INTO test \"error\", returned " << nb << std::endl; std::cout << "INSERT INTO test \"error\", returned " << nb << std::endl;
abort(); // unexpected success : abort the example program return EXIT_FAILURE; // unexpected success : exit the example program
// Commit transaction // Commit transaction
transaction.commit(); transaction.commit();
@ -271,7 +271,7 @@ int main (void)
catch (std::exception& e) catch (std::exception& e)
{ {
std::cout << "SQLite exception: " << e.what() << std::endl; std::cout << "SQLite exception: " << e.what() << std::endl;
abort(); // unexpected error : abort the example program return EXIT_FAILURE; // unexpected error : exit the example program
} }
remove("transaction.db3"); remove("transaction.db3");
@ -309,7 +309,7 @@ int main (void)
else else
{ {
std::cout << "file " << filename_logo_png << " not found !\n"; std::cout << "file " << filename_logo_png << " not found !\n";
abort(); // unexpected error : abort the example program return EXIT_FAILURE; // unexpected error : exit the example program
} }
fp = fopen("out.png", "wb"); fp = fopen("out.png", "wb");
@ -327,24 +327,24 @@ int main (void)
size = colBlob.getBytes (); size = colBlob.getBytes ();
std::cout << "row (" << query.getColumn(0) << ", size=" << size << ")\n"; std::cout << "row (" << query.getColumn(0) << ", size=" << size << ")\n";
size_t sizew = fwrite(blob, 1, size, fp); size_t sizew = fwrite(blob, 1, size, fp);
assert(sizew == size); SQLITE_CPP_ASSERT(sizew == size);
fclose (fp); fclose (fp);
} }
} }
else else
{ {
std::cout << "file out.png not created !\n"; std::cout << "file out.png not created !\n";
abort(); // unexpected error : abort the example program return EXIT_FAILURE; // unexpected error : exit the example program
} }
} }
catch (std::exception& e) catch (std::exception& e)
{ {
std::cout << "SQLite exception: " << e.what() << std::endl; std::cout << "SQLite exception: " << e.what() << std::endl;
abort(); // unexpected error : abort the example program return EXIT_FAILURE; // unexpected error : exit the example program
} }
remove("out.png"); remove("out.png");
std::cout << "everything ok, quitting\n"; std::cout << "everything ok, quitting\n";
return 0; return EXIT_SUCCESS;
} }