java how to catch multiple exceptions code example
Example 1: java catch multiple exceptions
catch(IOException | SQLException ex){
logger.error(ex);
throw new MyException(ex.getMessage());
}
Example 2: Java catch multiple exceptions and rethrow exception
try
{
}
catch(SQLException | IOException e)
{
logger.log(e);
}
catch(Exception e)
{
logger.severe(e);
}
Example 3: Java catch multiple exceptions and rethrow exception
try
{
}
catch(SQLException e)
{
logger.log(e);
}
catch(IOException e)
{
logger.log(e);
}
catch(Exception e)
{
logger.severe(e);
}