简体   繁体   English

如何修复从poco库收到的异常?

[英]How to Fix the exception received from poco library?

When client create an instant on SenderThread . 当客户端在SenderThread上创建一个瞬间。 It can send data to and from. 它可以发送数据和从中发送数据。 But when client goes for suspend mode and come back from suspend. 但是当客户端进入暂停模式并从暂停状态返回时。 The last created threads get exception on resume. 最后创建的线程在恢复时获得异常。 and no data is sent. 并且没有数据被发送。

Exception Details received : 收到的例外详情:

displayText = Exception displayText = Exception

message = message =

name = Exception name = Exception

className = N4Poco9ExceptionE className = N4Poco9ExceptionE

Here is the code: 这是代码:

class SenderThread: public Poco::Runnable
{
public:
    MyThread(const std::string& msg):
        Msg(msg);
    {
    }

    void run()
    {
        try {
        SendData(msg);
       } catch(Exception exp) {
           std::cout<<"displayText = "<<e.displayText()<<std::endl;
           std::cout<<"message = "<<e.message()<<std::endl;
           std::cout<<"name = "<<e.name()<<std::endl;
           std::cout<<"className = "<<e.className()<<std::endl;

        }

    }

private:
    std::string Msg;

};

How can I get more details on the exception and how to handle this exception?. 如何获得有关异常以及如何处理此异常的更多详细信息?

Edited After Günter Obiltschnig comment: 修改后的GünterObiltschnig评论:

I am able to catch the proper exception. 我能够抓住正确的例外。

 displayText = Invalid argument 
 name = Invalid argument 

Some time i see socket closed exception. 有段时间我看到套接字关闭异常。 When system goes to suspend mode then all the socket is closed by system(os). 当系统进入挂起模式时,系统(os)将关闭所有套接字。 Now upon resume application tries to open the socket again it throw error in the Poco::Net::Socket::Socket(Poco::Net::Socket const&). 现在,在恢复应用程序尝试再次打开套接字时,它会在Poco :: Net :: Socket :: Socket(Poco :: Net :: Socket const&)中抛出错误。 any help on this please 对此有任何帮助

You have to catch the exception by (const) reference in order to get useful information out of it. 您必须通过(const)引用捕获异常,以便从中获取有用的信息。

catch (const Poco::Exception& exc)
{
    std::cerr << exc.displayText() << std::endl;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM