Search code examples
eclipsejava-8unhandled-exception

Multiple exception catch block java 8 eclipse


I'm getting an unhandled message exception for IOException. As you can see in the pasted code I've handled the IOException. The JDK for both eclipse & the project is Java 8 update 121 so I know catching multiple exceptions is supported. What am I doing wrong?

    try (InputStream inputStream = BatchMessageProperties.class.getClassLoader().
            getResourceAsStream(propertiesFileName)) {

        load(inputStream);
        //need to make sure all properties are present & not null.
        validate(this);

    } catch (IOException | InvalidBatchMessagePropertiesFileException ex) {

        logger.error(ex.getLocalizedMessage());
        ex.printStackTrace();
        throw ex;
    }

Solution

  • You do rethrow ex inside your catch block, which may be an IOException, right?