catching an exception - Programmer

This is a discussion on catching an exception - Programmer ; Hi, there's an Exception thrown in a DLL, if i catch that exception, how can i get some more information about it? E.g. the string that shows the reason for that exception? Best regards, Torsten....

+ Reply to Thread
Results 1 to 3 of 3

Thread: catching an exception

  1. catching an exception

    Hi,

    there's an Exception thrown in a DLL, if i catch that
    exception, how can i get some more information about it?

    E.g. the string that shows the reason for that exception?


    Best regards,
    Torsten.


  2. Re: catching an exception

    > Hi,
    >
    > there's an Exception thrown in a DLL, if i catch that
    > exception, how can i get some more information about it?
    >
    > E.g. the string that shows the reason for that exception?
    >
    >
    > Best regards,
    > Torsten.


    Hi Torsten,

    first you need the type of the exception
    e.g.
    try
    {
    .... some code ... throw((int) 9); //exception
    .... some code ... throw((DWORD) 6);//exception
    .... some code ... throw((char) 3);//exception
    .... some code ... throw("Error");//exception
    }
    catch(DWORD d) //catches only a throw from type DWORD!
    {
    //.... error-handling ...
    }
    catch(int i)//catches only a throw from type int!
    {
    ..... error-handling ...
    }
    catch(char c)//catches only a throw from type char!
    {
    ..... error-handling ...
    }
    catch(char* c)//catches only a throw from type char*!
    {
    ..... error-handling ...
    }
    catch(...)//catches all (other) exceptions!
    {
    //.... error-handling ...
    //e.g. do this
    DWORD LastError = ::GetLastError();
    }

    For more informations about the errorcode look for "FormateMessage()"
    http://msdn.microsoft.com/library/de...us/debug/base/
    formatmessage.asp


    HTH

    Regards
    Frank




  3. Re: catching an exception

    "Frank Kaehler" wrote in message news:...
    > > Hi,
    > >
    > > there's an Exception thrown in a DLL, if i catch that
    > > exception, how can i get some more information about it?
    > >
    > > E.g. the string that shows the reason for that exception?
    > >
    > >
    > > Best regards,
    > > Torsten.

    >
    > Hi Torsten,
    >
    > first you need the type of the exception
    > e.g.
    > try
    > {
    > ... some code ... throw((int) 9); //exception
    > ... some code ... throw((DWORD) 6);//exception
    > ... some code ... throw((char) 3);//exception
    > ... some code ... throw("Error");//exception
    > }
    > catch(DWORD d) //catches only a throw from type DWORD!
    > {
    > //.... error-handling ...
    > }
    > catch(int i)//catches only a throw from type int!
    > {
    > .... error-handling ...
    > }
    > catch(char c)//catches only a throw from type char!
    > {
    > .... error-handling ...
    > }
    > catch(char* c)//catches only a throw from type char*!
    > {
    > .... error-handling ...
    > }
    > catch(...)//catches all (other) exceptions!
    > {
    > //.... error-handling ...
    > //e.g. do this
    > DWORD LastError = ::GetLastError();
    > }
    >
    > For more informations about the errorcode look for "FormateMessage()"
    > http://msdn.microsoft.com/library/de...us/debug/base/
    > formatmessage.asp
    >
    >
    > HTH
    >
    > Regards
    > Frank


    Here's the link to references of catch/throw exception code in the
    VNC (Open source remote control program).

    http://www.slink-software.com/W/SL_T...0/LN_148#L_145

+ Reply to Thread