Search code examples
javaexceptionthrow

How in java throw again exception the same type?


I need to restore data on exception and after throw exception of the same type. Is it possible if in compile time I don't know the type of exception? Thanks.


Solution

  • Have you tried this:

    try
    {
      // your code here.
    }
    catch (Exception exception)
    {
      // your code here.
      throw exception;
    }