Answers for "java throws multiple exceptions"

3

Java catch multiple exceptions and rethrow exception

// syntax in java 7 Java catch multiple exceptions and rethrow exception
try
{
   // code that throw exceptions 1 and 3
}
catch(SQLException | IOException e)
{
   logger.log(e);
}
catch(Exception e)
{
   logger.severe(e);
}
Posted by: Guest on November-25-2020
2

Java catch multiple exceptions and rethrow exception

// Before java 7 - syntax Java catch multiple exceptions and rethrow exception
try
{
   // code that throw exceptions 1 and 3
}
catch(SQLException e)
{
   logger.log(e);
}
catch(IOException e)
{
   logger.log(e);
}
catch(Exception e)
{
   logger.severe(e);
}
Posted by: Guest on November-25-2020
11

java catch multiple exceptions

catch(IOException | SQLException ex){
     logger.error(ex);
     throw new MyException(ex.getMessage());
}
Posted by: Guest on February-29-2020
3

java throws multiple exceptions

public class MyClass implements MyInterface {
  public void find(int x) throws A_Exception, B_Exception{
    ----
    ----
    ---
  }
}
Posted by: Guest on February-29-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language