Recover context from exception
问题 Consider the following resource managing class class FooResouce { public: explicit FooResouce(T arg_to_construct_with) { m_foo = create_foo_resouce(arg_to_construct_with); if(m_foo == nullptr) {throw SomeException(get_foo_resource_error(), arg_to_construct_with);} } // Dtor and move operations // Other FooResource interaction methods private: foo_resource_t* m_foo; }; Now, when we decide to catch the exception and format an error message, it's easy to know what caused the exception at the