4

When client create an instant on 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

message =

name = Exception

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:

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). Now upon resume application tries to open the socket again it throw error in the Poco::Net::Socket::Socket(Poco::Net::Socket const&). any help on this please

Community
  • 1
  • 1
rim
  • 351
  • 2
  • 15

1 Answers1

4

You have to catch the exception by (const) reference in order to get useful information out of it.

catch (const Poco::Exception& exc)
{
    std::cerr << exc.displayText() << std::endl;
}
Günter Obiltschnig
  • 1,536
  • 11
  • 13
  • I am able to catch the proper exception. displayText = Invalid argument name = Invalid argument and some time i see socket closed exception. When after system goes to suspend mode then all the socket is closed by system. Now upon resume application tries to open the socket again it throw error in the Poco::Net::Socket::Socket(Poco::Net::Socket const&). any help on this please – rim Jul 08 '19 at 05:00
  • My code crash when fresh re-connection after suspend is done @Günter Obiltschnig Process 909343 terminated SIGSEGV code=1 fltno=11 libpos.so@_ZN4Poco3Net6SocketC1ERKS1_+0x0000000000000018) mapaddr=000000000023d8 – rim Jul 08 '19 at 15:21