The problem with exception handle in QML 2 plugin



  • Hi everyone!

    I have the QML 2 plugin with method which crashed. I try to add the try..catch block for method but the catch section not called when method generating exception this is how to look my method:
    @
    QString MdlLogParser::description(QString prefix)
    {
    try
    {
    QString res = prefix + "MdlLogParser (Object)\n";
    QString newPrefix = "| ";

        QString subPrefix = prefix + newPrefix;
    
        res.append(prefix + newPrefix + QString("logContent = %1\n").arg(m_logContent));
        res.append(prefix + newPrefix + QString("logFilePath = %1\n").arg(m_logFilePath));
        res.append(prefix + newPrefix + QString("version = %1\n").arg(m_version));
    
        if(m_loggerInfo != NULL)
        {
            res.append(m_loggerInfo->description(subPrefix));
        }
        else
        {
            res.append(prefix + newPrefix + QString("loggerInfo = NULL\n"));
        }
    
        if(m_deviceInfo != NULL)
        {
            res.append(m_deviceInfo->description(subPrefix));
        }
        else
        {
            res.append(prefix + newPrefix + QString("deviceInfo = NULL\n"));
        }
    
        if(m_appInfo != NULL)
        {
            res.append(m_appInfo->description(subPrefix));
        }
        else
        {
            res.append(prefix + newPrefix + QString("appInfo = NULL\n"));
        }
    
        res.append(m_crashLog->description(subPrefix)); //generating exception because m_crashLog is NULL. I fix this when add the if(m_crashLog == NULL). The method description(subPrefix) for object m_crashLog have try...catch too.
    
        if(m_error != NULL)
        {
            res.append(m_error->description(subPrefix));
        }
        else
        {
            res.append(prefix + newPrefix + QString("error = NULL\n"));
        }
    
        res.append(prefix + newPrefix + QString("methods (Array)\n"));
        foreach(MdlLogMethod* method, m_methods)
        {
            res.append(method->description(subPrefix + newPrefix));
        }
        res.append(prefix + newPrefix + QString("methods\n"));
        res.append(prefix + newPrefix + QString("classes (Array)\n"));
        foreach(MdlLogClass* classObj, m_classes)
        {
            res.append(classObj->description(subPrefix + newPrefix));
        }
        res.append(prefix + newPrefix + QString("classes\n"));
        res.append(prefix + newPrefix + QString("messages (Array)\n"));
        foreach(MdlLogMessage* msg, m_messages)
        {
            res.append(msg->description(subPrefix + newPrefix));
        }
        res.append(prefix + newPrefix + QString("messages\n"));
        res.append(prefix + newPrefix + QString("systemMessage (Array)\n"));
        foreach(MdlLogMessage* msg, m_systemMessage)
        {
            res.append(msg->description(subPrefix + newPrefix));
        }
        res.append(prefix + newPrefix + QString("systemMessage\n"));
        res.append(prefix + newPrefix + QString("images (Array)\n"));
        foreach(MdlLogImage* img, m_images)
        {
            res.append(img->description(subPrefix + newPrefix));
        }
        res.append(prefix + newPrefix + QString("images\n"));
        res.append(prefix + newPrefix + QString("sessions (Array)\n"));
        foreach(MdlLogSession* session, m_sessions)
        {
            res.append(session->description(subPrefix + newPrefix));
        }
        res.append(prefix + newPrefix + QString("sessions\n"));
        if(m_methodsInformer != NULL)
        {
            res.append(m_methodsInformer->description(prefix + newPrefix));
        }
        else
        {
            res.append(prefix + newPrefix + QString("methodsInformer = NULL\n"));
        }
        res.append(prefix + "MdlLogParser\n");
    
        return res;
    }
    catch(std::exception& exception)
    {
        qDebug()<<"Exception: "<<exception.what();
        return prefix+"NULL\n";
    }
    

    }
    @

    Can you tell me what I do wrong? Thanks for any help!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.