I'm porting a library I wrote for Java to .NET C# and I'm dealing with differences in exception handling between the two worlds.
In particular I have an abstract
class that I use as base class to implement several services. In this class I have these methods:
public void MyConcreteMethod(){
//...
try {
initialize();
} catch(InitializationException ex){
// ...
}
// ...
}
public abstract void initialize() throws InitializationException;
Every extending class must implement his way to initialize
and I clearly know that I need to handle some possible InitializationException
.
In C# I converted my code like this:
public void MyConcreteMethod(){
//...
Initialize();
// ...
}
public abstract void Initialize();
but this way I haven't a clear information about possible initialization problems: in some classes I could throw exception, and in others I could not.
So should I hanlde them in MyConcreteMethod
? Which exception shold I catch? A generic Exception
?