1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Rep Power

    handling any exception in a try catch block?


    I have a situation where by I have functionA throwing exceptions, I don't really care about the kind of exceptions thrown from functionA just that there maybe many of them and of differing type.

    I want to execute functionA and handle any exception thats thrown from executing functionA and just discard them, maybe make a note of them somewhere but thats beside the point.

    Is it possible to make this water tight? .. no exceptions thrown in functionA will get out

    functionA is inside of a win32 dll, it runs lots of code and the nature of what it does makes it unreliable. I am not using MFC and would like to keep this as standard as possible.

    In Java the answer to the above question would be, put a try catch block round the function call and catch the Exception class:

    try {
    }catch(Exception e)

    I can't seem to find any information relating to this, wether there is a base class for all the exceptions thrown to catch, is there? and will that catch all exceptions?


  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Feb 2001
    Rep Power

    My book says,


    will handle an exception of any type. In addition, it says that all exceptions defined in the standard library are derived from the standard class std::exception, so you can use a base class handler to catch any exceptions derived from std::exception,

    catch(exeception& rEX)
    Last edited by 7stud; April 5th, 2003 at 11:55 PM.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2002
    Seattle WA
    Rep Power
    The elipsis (...) is the proper way to do it. Read up on what it's used for.

    Basicly, it signifies an argument list of unknown type and quantity. Beyond using it for catch-all statements, you can also use it in function declarations that accept variable parameter types/quantities. Though it's rarely used in functions since it defeats the inherrent typesafety of C++, many stl functions are defined using them. Think functions that accept almost any number of arguments, like the printf() family...

IMN logo majestic logo threadwatch logo seochat tools logo