Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Handling Exception: third party library



  • First of all, I read other posts about Qt and Exceptions (like this), but I not found a solution to my case.

    I'm using a third party C++ library called HighFive (github link) in my Qt GUI project to write and read data in HDF5 format.

    It's working. I can read and write data with this.
    The problem is that: Every time when I try to read/write data using this library, the library emit a exception and Qt Creator IDE shows it in a GUI popup window and I can't catch it in a try/catch block.
    This simple example below is a completly new Qt Console application project created just to test the try/catch block:

    int main(int argc, char *argv[])
    {
        QCoreApplication app(argc, argv);
    
        // Create a HDF5 file on disk:
        H5Easy::File file("test.h5", H5Easy::File::Overwrite);
        // Create some data:
        std::vector<double> data = { 1, 2, 3, 4, 5 };
    
        // Try to write data into the HDF5 file:
        try {
            H5Easy::dump(file, "/path/to/my/data", data);
        } catch (...) {
            qDebug() << "I CATCH A EXCEPTION";
        }
    
        return app.exec();
    }
    

    When the debugger hits the line:

    H5Easy::dump(file, "/path/to/my/data", data);
    

    The debugger goes to a internal HighFive library file that emits the exception (GUI popup window):
    bf9f536a-179a-47b7-b1ba-39afc5e46405-image.png

    What can I do inside my main.cpp to handle this exception and not get this popup window above?

    PS.: I talked to the HighFive team about it. They asked me to test the same example using Microsoft Visual Studio 2019 and it works great without erros or exceptions. So they think that this case is about some special configuration on the Qt Creator IDE.
    You can see the discussion here.

    My system:

    • Windows 10 x64
    • Qt Creator IDE 4.10.1 (32 bits)
    • Visual Studio 2019 Enterprise

    Compiler and Debugger:
    69ce2c46-5b71-4cfc-a353-67317e6d7092-image.png

    Again: All is working! I just want to "disable/mute" this exceptions or catch it in a try/catch block.
    How can I do that?


  • Lifetime Qt Champion

    Hi,

    One thing that is indeed different is the debugger. Unless it changed recently, the Visual Studio debugger was only available to Visual Studio itself. You had to install a standalone debugger which might be different that the one embedded in Visual Studio.



  • @SGaist Well...I don't know...
    I was thinking that this debugger (image above in red) is the VS 2019 debugger and Qt is using the same debugger.

    C:\ Program Files (x86)\Wnidows Kits\10\Debuggers\x64\cdb.exe
    

    Is it not the same?


  • Lifetime Qt Champion

    As I said, things may have changed with VS2019. Do you remember its installation ?



  • @SGaist yes...the installation was clear and it said nothing about the compiler/debugger name or type.
    It was like: Next, next, next, finish...done!


  • Lifetime Qt Champion

    Are you talking about the Qt installation or the VS2019 one ?


Log in to reply