what is a first-chance-exception?

visual-studio, visual-studio-2010

Solution

So why do I get the error?

It is not an error, it is just a debugger notification. There are several, you for example also see notifications when a thread exits or a DLL gets loaded or the program terminates. These are the kind of events in a program that usually have a lot of impact on the program, a C++ exception is an exceptional event so the debugger lets you know about that.

The "first chance" exception doesn't have to turn into an unhandled exception that aborts your program. And it didn't, you wrote try/catch in your code and caught the exception. Still good to know about this, maybe your catch handling is broken and your program misbehaves. It very commonly is since exceptions should be exceptional so don't get tested very often. You do that with Debug + Exceptions, tick the Thrown checkbox for C++ exceptions. The debugger now automatically breaks the program on the first chance exception notification, giving you a shot at finding out exactly why the exception was thrown. Very useful.

You don't have to look at these notifications, right-click the Output window and untick the "Exception messages" option.

Feature, not a bug.

Problem

I'm getting a `First-chance exception at 0x75FA2EEC in x.exe: Microsoft C++ exception: boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::property_tree::ptree_bad_path> > at memory location 0x006AE774`. In my code, I thought I have handled them already: ``` const ptree& v; std::string value; try { value = v.get<std::string>("<xmlattr>.Value"); } catch(ptree_bad_path&) { value = v.get_value<std::string>(); } ``` (According to the docs.) So why do I get the error? It seems to just ignore the error then and continues with execution.

Original source