A
annex
hi, i have some queries about handling exceptions, i'm using Borland c++
Builder 6.
1) what's the best way to catch multiple exceptions in one catch statement?
is this possible? for e.g i want to catch 2 exceptions; MyEx1 and MyEx2,
both to be handled in the same way. how to do this?
try
{
doSomething();
}
catch (MyEx1)
{
sameCode();
}
catch (MyEx2)
{
sameCode();
}
note that both exceptions are to be handled using the same piece of code.
2) what's the difference btw catch(...) and catch(Exception). will
catch(Exception) catch all unhandled exceptions also like does catch(...) ?
try
{
doSomething();
}
catch(...)
{
handle();
}
and
try
{
doSomething();
}
catch(Exception)
{
handle();
}
Builder 6.
1) what's the best way to catch multiple exceptions in one catch statement?
is this possible? for e.g i want to catch 2 exceptions; MyEx1 and MyEx2,
both to be handled in the same way. how to do this?
try
{
doSomething();
}
catch (MyEx1)
{
sameCode();
}
catch (MyEx2)
{
sameCode();
}
note that both exceptions are to be handled using the same piece of code.
2) what's the difference btw catch(...) and catch(Exception). will
catch(Exception) catch all unhandled exceptions also like does catch(...) ?
try
{
doSomething();
}
catch(...)
{
handle();
}
and
try
{
doSomething();
}
catch(Exception)
{
handle();
}