Esempio n. 1
0
    {
    public:
        virtual HRESULT STDMETHODCALLTYPE GetClassID(CLSID* /*class_id_out*/)
        {
            try
            {
                throw com_error("Test error message", E_NOTIMPL);
            }
            COMET_CATCH_CLASS_INTERFACE_BOUNDARY("GetClassID", "error_object")
        }
    };

    com_ptr<IPersist> broken_object = new error_object();

    CLSID clsid = CLSID();
    HRESULT hr = broken_object->GetClassID(&clsid);

    BOOST_REQUIRE_EQUAL(hr, E_NOTIMPL);

    com_error error = com_error_from_interface(broken_object, hr);
    BOOST_CHECK_EQUAL(error.s_str(), "Test error message");
    BOOST_CHECK_EQUAL(error.source().s_str(), "error_object.GetClassID");
}


// Test that error info is correct even when the exception occurs inside a
// call to a contained object and that call does not have its error info
// specifically caught and rethrow.
BOOST_AUTO_TEST_CASE( contained_exceptions_propagate_out )
{
    class error_object : public simple_object<IPersist>