Can exceptions automatically provide details about their environment?
c++, exception
Solution
Presuming that your C++ compiler supports `__FUNCTION__` (or `__func__` in C++11) you can define AUTO_EXCEPTION as:
#define AUTO_EXCEPTION( msg ) std::runtime_error( std::string(__FUNCTION__) + ": " + msg )
Problem
What I would like to do: ``` struct A { void f() { throw auto_exception("something went wrong"); } } class Foo { void bar() { throw auto_exception("step 2 failed"); } } ``` The exception's `what()` string should read, respectively: ``` "Exception in A::f(). something went wrong" "Exception in Foo::bar(). step 2 failed" ``` Is this possible?