Is it possible without using an additional variable to find out what exception was caught in the catch clause and then throw it again from the finally clause?
public void exceptionalFunction() throws Exception
{
try
{
// exception causing code
}
catch (TypeAException e)
{
// exception specific logic
}
catch (TypeBException e)
{
// exception specific logic
}
catch (TypeCException e)
{
// exception specific logic
}
finally
{
// throw the exception that was caught, if one was caught.
}
}
Not without using an additional variable. Without using an additional variable you could only throw again the exception after the exception specific logic: