Handling an Exception

When a [b]throw[/b] has been performed from a class, and this is [b]catch[/b]ed somewhere else, how can I 'correct the exception'? That is, how do I tell that the exception has been handled and I don't need an error message?

Below I have a class that throws an exception, as well as code catching this exception. How do I undo the exception message?

[code]

class Test
{
public:
Test() {}
void doThrow()
{
if (random(5)==0)
throw Exception("Random(5)==0");
}
};

void __fastcall TForm1::Button1Click(TObject *Sender)
{
Test test;
try
{
test.doThrow();
}
catch(Exception& exception)
{
if (exception.Message == "Random(5)==0")
{
//Aha, a harmless error!
//Try to fix the error message, e.g.
//exception.Free(); (doesn't work)
}
}
}
[/code]

Thanks in advance,
bilderbikkel
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories