dbTalk Databases Forums  

Exceptions in mysql++

mailing.database.mysql-plusplus mailing.database.mysql-plusplus


Discuss Exceptions in mysql++ in the mailing.database.mysql-plusplus forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Jonatan Taminau
 
Posts: n/a

Default Exceptions in mysql++ - 10-11-2005 , 08:08 AM






Hello,

I'm trying to use exceptions in mysql++ but i can only catch exceptions of
type 'exception'.

For example, in:

try {
query.execute("blabla");
}
catch(BadQuery& e) {
cout << "Bad Query: " << e.what() << endl;
}
catch(Exception& e) {
cout << "Exception: " << e.what() << endl;
}
catch(exception& e) {
cout << "DAMN!" << endl;
}

The BadQuery (and even the Exception) will be never catched... The result is
always: DAMN! This is ofcourse quite annoying since i have to do:

try {
query << "blablaba";
queryString = query.str();
}
catch(exception& e) {
cout << "unable to execute: " << queryString << endl;
}


I'm using mysql++-2.0.4 and i ran the configure script with
'--with-exception' as argument. Furthermore i've done:

connection con(true);
con.connect(...);


I hope someone can give me some advice,
Jonatan



--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw


Reply With Quote
  #2  
Old   
Warren Young
 
Posts: n/a

Default Re: Exceptions in mysql++ - 10-11-2005 , 11:16 AM






Jonatan Taminau wrote:
Quote:
catch(exception& e) {
cout << "DAMN!" << endl;
}
What does it say if you replace that cout statement with:

cout << typeid(e).name << endl;

? (Syntax may be wrong...adjust as necessary.)

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #3  
Old   
Jonatan Taminau
 
Posts: n/a

Default Re: Exceptions in mysql++ - 10-12-2005 , 08:54 AM



Quote:
Jonatan Taminau wrote:
catch(exception& e) {
cout << "DAMN!" << endl;
}

What does it say if you replace that cout statement with:

cout << typeid(e).name << endl;

? (Syntax may be wrong...adjust as necessary.)
I get:

PSt9exception




--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #4  
Old   
Warren Young
 
Posts: n/a

Default Re: Exceptions in mysql++ - 10-12-2005 , 10:26 PM



Jonatan Taminau wrote:
Quote:
I get:

PSt9exception
....and if you say:

cout << e.what() << endl;

instead?

--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #5  
Old   
Jonatan Taminau
 
Posts: n/a

Default Re: Re: Exceptions in mysql++ - 10-14-2005 , 02:05 AM



Quote:
...and if you say:

cout << e.what() << endl;

instead?
Then I get:

"You have an error in your SQL syntax; check the manual that corresponds
to your MySQL server version for the right syntax to use near 'blabla' at
line 1"

Which is ok, the only strange problem is that it's of type exception so I
can't do any more robust error handling...



--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #6  
Old   
Chris Frey
 
Posts: n/a

Default Re: Re: Exceptions in mysql++ - 10-14-2005 , 02:18 AM



On Fri, Oct 14, 2005 at 09:07:50AM +0200, Jonatan Taminau wrote:
Quote:
Which is ok, the only strange problem is that it's of type exception so I
can't do any more robust error handling...
I don't think you mentioned this earlier, but what compiler are you using?

And just to make sure, I assume there are no other mysql++ headers in
various spots on your system that might be getting included?

- Chris


--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #7  
Old   
Jonatan Taminau
 
Posts: n/a

Default Re: Re: Exceptions in mysql++ - 10-14-2005 , 03:26 AM



Quote:
On Fri, Oct 14, 2005 at 09:07:50AM +0200, Jonatan Taminau wrote:
Which is ok, the only strange problem is that it's of type exception so I
can't do any more robust error handling...

I don't think you mentioned this earlier, but what compiler are you using?

And just to make sure, I assume there are no other mysql++ headers in
various spots on your system that might be getting included?

- Chris
I'm working in Xcode 2.1, which uses the GNU C/C++ Compiler 4.0.
The only file I include is <mysql++.h> and I had to include the following
linker flags:
-bind_at_load -lmysqlclient -lmysqlpp

BTW, My apologies for creating an unnecessary new thread but how can you
reply to messages without being subscribed to the mailinglist? (I just send
mails to the plusplus (AT) lists (DOT) mysql.com address with subject the name of the
thread)

Jonatan



--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #8  
Old   
Chris Frey
 
Posts: n/a

Default Re: Re: Exceptions in mysql++ - 10-14-2005 , 09:05 AM



On Fri, Oct 14, 2005 at 10:28:44AM +0200, Jonatan Taminau wrote:
Quote:
I'm working in Xcode 2.1, which uses the GNU C/C++ Compiler 4.0.
The only file I include is <mysql++.h> and I had to include the following
linker flags:
-bind_at_load -lmysqlclient -lmysqlpp
Is it possible to compile without -bind_at_load? Just to eliminate
possible variables here.


Quote:
BTW, My apologies for creating an unnecessary new thread but how can you
reply to messages without being subscribed to the mailinglist? (I just send
mails to the plusplus (AT) lists (DOT) mysql.com address with subject the name of the
thread)
I am subscribed, with one of my other addresses: cdfrey (AT) netdirect (DOT) ca.

- Chris


--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
  #9  
Old   
Jonatan Taminau
 
Posts: n/a

Default Re: Re: Exceptions in mysql++ - 10-17-2005 , 08:31 AM



Quote:
Is it possible to compile without -bind_at_load? Just to eliminate
possible variables here.
Without that flag I just get a warning message:

- warning suggest use of -bind_at_load, as lazy binding may result in errors
or different symbols being used

For the rest nothing changed.




--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe: http://lists.mysql.com/plusplus?unsu...ie.nctu.edu.tw



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.