I have 2 custom exceptions defined in my project. Each of which should be handled differently.
Exception A
{
errCode
}
Exception B
{
// other stuff
errCode
}
The main caller method, is like this.
Should the code to write into the tables be within the exception class (say a method called handleItself() ). Or should the caller method handle it?
There are multiple entry points. And I am hesitant to have the handling logic lying around everywhere.
Which is the better way?
catch (A a)
{
insert to table X
}
catch (B b)
{
// do other stuff
insert to table Y
}
or
catch (A a)
{
a.handleItself();
}
catch (B b)
{
// do other stuff
b.handleItself();
}