Opened 10 years ago

Closed 10 years ago

#8312 closed Bugs (fixed)

Test definitions for throw_exception_test.cpp swapped?

Reported by: greg.julus@… Owned by: Emil Dotchevski
Milestone: To Be Determined Component: exception
Version: Boost 1.52.0 Severity: Problem
Keywords: Cc:

Description

I was attempting to learn how to extract the file, function, & line number from a caught exception for logging and noticed the following in boost_throw_exception_test found in throw_exception_test.cpp:

char const * const * file=boost::get_error_info<boost::throw_function>(x);
char const * const * function=boost::get_error_info<boost::throw_file>(x);

It appears the file is retrieving the function name and vice versa. I didn't check to see if there were other instances of this occurrance.

I'm novice so I may be very wrong. FYI: I was in this area because I couldn't figure out from the documentation how to access the values placed by BOOST_THROW_EXCEPTION. I finally figured out the following based upon what I found in your test file:

if( char const * const * file=boost::get_error_info<boost::throw_file>(e) ) cout << "The File where it happened:" << *file << "\n";
if( char const * const * function=boost::get_error_info<boost::throw_function>(e) ) cout << "The Function where it happened:" << *function << "\n";
if( int const * line=boost::get_error_info<boost::throw_line>(e) ) cout << "The Line where it happened:" << *line << "\n";

-g

Change History (1)

comment:1 by Emil Dotchevski, 10 years ago

Resolution: fixed
Status: newclosed

Fixed in trunk revision 83588. Thanks!

Note: See TracTickets for help on using tickets.