CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2005
    Posts
    282

    print information about unknown exceptions

    Hello,
    is it possible to get some information about an unknown (or unexpected) exception?
    e.g

    try{
    //...do something
    }
    catch(...)
    {
    //print some information
    }

    in this case I want to know which exception was thrown..in other languages (java, c#...) this is possible. But I'm not sure if it is also possible in c++

    Best regards
    Hansjörg

  2. #2
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: print information about unknown exceptions

    If you use ... it's not possible. You are ignoring the exception type and then want to know what exeption?
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  3. #3
    Join Date
    Apr 2007
    Posts
    48

    Re: print information about unknown exceptions

    There's no given base interface/class/pattern that exceptions must follow, so nope. Usually exceptions are derived from std::exception though, so you could do something such as:
    Code:
    try
    {
      // ...
    }
    catch (std::exception& e)
    {
      // Log exception with information provided from e.what()
    }
    catch (...)
    {
      // Log exception with a message such as "unknown exception"
    }

  4. #4
    Join Date
    Feb 2005
    Location
    "The Capital"
    Posts
    5,306

    Re: print information about unknown exceptions

    There are some libraries, example Roguewave - where the base exception class is not std::exception but one of their own, so if you are using different libraries - make sure you don't miss their base catches.

  5. #5
    Join Date
    Dec 2005
    Posts
    282

    Re: print information about unknown exceptions

    thanks..bad news...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured