List:MySQL++« Previous MessageNext Message »
From:Earl Miles Date:March 11 2005 1:39am
Subject:Minor problem with the resetdb
View as plain text  
After the exceptions change there's a minor failure in the resetdb.cpp 
that fails to check for an exception if it is unable to create the 
sample database (which seems like a very common early error). Simply 
adding a try/catch around that bit fixes it. Here's the diff, sent as an 
attachment to prevent my mailer from word-wrapping it and destroying the 
diff.


--- ../../orig/mysql++-1.7.31/examples/resetdb.cpp      2005-03-05 00:07:20.000000000
-0800
+++ resetdb.cpp 2005-03-10 17:40:05.000000000 -0800
@@ -28,17 +28,24 @@
                // Couldn't switch to the sample database, so assume that it
                // doesn't exist and create it.  If that doesn't work, exit
                // with an error.
-               if (con.create_db(kpcSampleDatabase)) {
-                       cerr << "Failed to create sample database." << endl;
-                       return 1;
+               try
+               {
+                       if (con.create_db(kpcSampleDatabase)) {
+                               cerr << "Failed to create sample database." <<
endl;
+                               return 1;
+                       }
+                       else if (!con.select_db(kpcSampleDatabase)) {
+                               cerr << "Failed to select sample database." <<
endl;
+                               return 1;
+                       }
+                       else {
+                               created = true;
+                       }
                }
-               else if (!con.select_db(kpcSampleDatabase)) {
-                       cerr << "Failed to select sample database." << endl;
+               catch (exception& er) {
+                       cerr << "Failed to create sample database: " <<
er.what() << endl;
                        return 1;
                }
-               else {
-                       created = true;
-               }
        }

        mysqlpp::Query query = con.query();     // create a new query object

Thread
Minor problem with the resetdbEarl Miles11 Mar
  • Re: Minor problem with the resetdbWarren Young11 Mar
    • Re: Minor problem with the resetdbEarl Miles11 Mar
      • Re: Minor problem with the resetdbWarren Young11 Mar
    • Re: Minor problem with the resetdbWarren Young11 Mar
      • Re: Minor problem with the resetdbEarl Miles11 Mar
        • Re: Minor problem with the resetdbWarren Young12 Mar
          • Re: Minor problem with the resetdbEarl Miles12 Mar
Re: Minor problem with the resetdbWarren Young12 Mar