Catching MySQL exception in POCO C++

A general discussion forum.
Posts: 1
Joined: 11 Oct 2011, 15:41

Catching MySQL exception in POCO C++

Postby chockablock » 12 Oct 2011, 03:34

Hi all,
I'm currently using MySQL libraries compiled using POCO C++. I encountered a problem: I couldn't catch any exception thrown by the library. Therefore, the program is always terminated without any message printed out the console, even I tried to catch Poco::Exception or std::exception. Anyone knows how to fix this issue? Below is a sample code fragment I used

Code: Select all

                //get a session from session pool.
      Session _session = (*sessionPool).get();
      return _session ;
   catch (SessionPoolExhaustedException spee)
      cout << "Session pool exhausted";
        catch (Exception& pocoEx)
      cout << "POCO exception";
   catch (exception ex)
      cout << "Exception";

Posts: 89
Joined: 08 Nov 2010, 17:29

Re: Catching MySQL exception in POCO C++

Postby marlowabnp » 17 Oct 2011, 20:39

I would catch by reference. That code you showed is catching by value. See Meyers for why programs should always throw by value and catch by reference.

-Andrew M.

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 2 guests