Hi,
Can somebody please advice me on raising/throwing custom exceptions?
Here is what I'm trying to do.

//MainFunction() will call SubFunction() to perform some ADO function.
MainFunction()
{
    try
   {
       SubFunction()

       //OtherFunction1
       //OtherFunction2
   }
   catch(...)
   {
      //to catch custom exceptions raised by me in SubFunction() so that it will bypass execution of OtherFunction1 and OtherFunction2. 
   }
}


SubFunction()
{
    try
    {
        //Perform ADOfunction such as SELECT statement

        //Raise my own exception to be caught by catch(...) in this function.
    {
    catch (CADOException e)
    {

    }
    catch(...)
    {
       //Catch own exception raised so that I can do my own processing.
       //After doing my own processing raise another exception to be caught by MainFunction.
    }
}

I've search the internet but couldn't find much info on catch(...).
By the way, in my searching of internet, i found that some people use "throw" to raise exception and some use "RaiseException".
Which one should I use to bypass OtherFunction1 and OtherFunction2?

Another thing is what should I do to supress the message box that prompt up when error occur?

You can use throw inside your try block.You can test a condition that throws an exception which will be caught by the first catch block that it meets.

try {
/* condition */ throw ("err");
}
catch (string s) {
}

You can use throw inside your try block.You can test a condition that throws an exception which will be caught by the first catch block that it meets.

try {
/* condition */ throw ("err");
}
catch (string s) {
}

Thanks..
Is it possible to throw in SubFunction's catch block and catch in MainFunction's catch block?
Thanks.

Sure.But why won't you try it ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.