Boost logo

Boost Users :

Subject: [Boost-users] [exception] What's wrong with boost::get_error_info?
From: Markus Schweiß (M.Schweiss_at_[hidden])
Date: 2009-05-29 09:02:12


Dear boost community,

I'm really new to using the boost library. Whatever, the first part I want to use is boost::exception. But already there start my problems:

I'm using 'boost::get_error_info<boost::throw_file>( myBoostException )' to retrieve the file name where my exception was thrown. The problem is that the returned 'const char*' pointer contains several wild characters at its end. It seems that the null-termination get lost somehow, somewhere.

The same is with 'boost::throw_function' and the string returned by 'boost::diagnostic_information( myBoostException )'!

For example, that is what I get from boost::diagnostic_information:
".\myFile.cppÍýýýý««««««««îþ(134): Throw in function MyClass::DoSomething()ÍÍÍÍÍÍ^ñ6
Dynamic exception type: class MyBoostException"

That's really strange because the strings are correctly stored to the boost::exception class attributes 'throw_function_' and 'throw_file_'.

So what do I wrong???
I would be so thankful when anyone could help me!

Following some detailed information:
- plattfrom: Windows XP SP3
- compiler: MS VC++ 8
- character set: multi-byte
- boost version: Release 1.37.0

code snippet for throwing my exception:

throw MyBoostException() << boost::throw_file( __FILE__ )
                         << boost::throw_line( __LINE__ )
                         << boost::throw_function( "MyClass::DoSomething()" );

code snippet for catching my exception:

catch( MyBoostException& myBoostException ) {
  std::string info = boost::diagnostic_information( myBoostException );
  const char* string = info.c_str();
}

My best regards,
Markus


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net