Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

Re: probleme with exeptions

From: Hai Nguyen <hai.scrub(at)gmail.com>
Date: Tue Oct 02 2007 - 15:57:20 EDT


It looks like your exception is coming from the underlining c++ string stuff and not from mysql++.

You can try adding in a catch all for std::exception or just a "...", e.g.

catch ( const std::exception& e) {
// do something
}
or
catch ( ... ) {
// do something
}

You also might want to do a stack trace to see what's generating that exception.

I hope that helps in some way...

  • Hai

Maarten Schrijvers wrote:
> Hervé accidently sent this to my email...
>
> Hello all,
>
> I using mysql++-2.3.2 on hp-ux
>
> I use a instance of
> mysqlpp::Connection m_db;
>
> the exception it's normaly at true.
>
> it's a example of use:
> void OnLoadCalendrier()
> {
>
> database.OpenConnection();
> string strlog;
>
> string sql;
> int nb_result;
> mysqlpp::Query query = database.m_db.query();
> mysqlpp::Row row;
> int nbgrp=0, nbcc=0;
>
> CCalendrier *cal;
> IteCal ite;
>
> try
> {
>
> sql = SQL_SELECT_CALENDRIER;
> query << sql;
> r->LogRoomSend((char*)sql.c_str());
>
> mysqlpp::Result res = query.store();
> nb_result = res.size();
> mysqlpp::Result::iterator i;
> if(res.num_rows()>=1)
> {
> for (i = res.begin(); i != res.end(); i++) {
> row = *i;
>
> cal = new CCalendrier();
> cal->id = atoi(row["id_calendrier"]);
>
> cal->decode(TYPE_JSEM,(char*)row["jsem"].c_str());
> cal->decode(TYPE_MOIS,
> (char*)row["mois"].c_str());
> cal->decode(TYPE_JOUR,
> (char*)row["jour"].c_str());
> cal->decode(TYPE_HEURE,
> (char*)row["heure"].c_str());
> cal->decode(TYPE_MINUTE,
> (char*)row["minute"].c_str());
> cal->decode(TYPE_SECONDE,
> (char*)row["seconde"].c_str());
>
> if(!row["time_deb"].is_null() &&
> !row["time_fin"].is_null() )
> {
>
> cal->add_timeperiode((char*)row["time_deb"].c_str(),(char*)row["time_fin"].c
>
> _str());
>
> }
>
> ite = ListeCal.searchPos(cal->id);
>
> if(ite == ListeCal.ListeCDC.end())
> ListeCal.ListeCDC.push_back(*cal);
> else
> {
> ite = ListeCal.searchPos(cal->id);
> ListeCal.ListeCDC.insert(ite,*cal);
> ite = ListeCal.searchPos(cal->id);
> ListeCal.ListeCDC.erase(ite);
>
> }
>
> }
> query.clear();
>
> }
> //cerr << "nbre Calendrier : "<< nb_result << endl;
> } catch ( const mysqlpp::BadQuery& er){ cerr << "Error: "
> << er.what() << endl;
> strlog ="GetTelephone() - Error: ";
> strlog += er.what() ;
> r->LogRoomSend((char*) strlog.c_str());
> } catch (const mysqlpp::BadConversion& er) {
> cerr << "Error: convertion "<< er.what()<< endl;
> strlog ="GetTelephone() - Error convertion : ";
> strlog += er.what() ;
> r->LogRoomSend((char*) strlog.c_str());
> }
> catch (const mysqlpp::Exception& er) {
> cerr << "Error: hummmm : \n" << er.what() << endl;
> strlog ="GetTelephone() - Error hummmm : ";
> strlog += er.what() ;
> r->LogRoomSend((char*) strlog.c_str());
> }
>
> }
>
> But after all exception the program abort.
>
>
> terminate called after throwing an instance of 'std::out_of_range'
> what(): basic_string::substr
> IOT Trap
> Abort(coredump)
>
> Please help-me.
>
> Hervé
>
>
>
>

-- 
MySQL++ Mailing List
For list archives: 
http://lists.mysql.com/plusplus
To unsubscribe:    
http://lists.mysql.com/plusplus?unsub=lists@pantek.com
Received on Tue Oct 2 15:57:45 2007

This archive was generated by hypermail 2.1.8 : Sun Oct 07 2007 - 10:03:25 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library