Reputation: 2042
I trying to throw inner exception in another exception through java Throwable
but IDE told my that you must surround it with try/cath
, What should I do to avoid from this problem?
try
{
//Some code
}
catch (IOException e)
{
Throwable cause = new Throwable();
cause.initCause(e);
throw cause.getCause();
}
Upvotes: 0
Views: 2481
Reputation: 25064
Change your method signature to this:
public void someMethod() throws IOException
{
//some code
}
Have a look at this site for some useful information on checked exceptions and a little on the difference between checked and unchecked exceptions
Upvotes: 2
Reputation: 60748
Declare IOException
as a checked exception in your function's signature.
Upvotes: 0