Je ne comprend pas ce point que je n'arrive pas a valider : La méthode gererExceptions ne doit pas enregistrer d'IOException.
Pourtant dans mon catch IOException, je n'appelle pas la fonction BEAN.journaliser()
package fr.codegym.task.task09.task0915;
import java.io.CharConversionException;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.file.FileSystemException;
/*
Capture d'exceptions personnalisées
*/
public class Solution {
public static BeanSansEtat BEAN = new BeanSansEtat();
public static void main(String[] args) {
try{
gererExceptions();
}
catch(FileSystemException e){
BEAN.journaliser(e);
System.out.println("FileSystemException");
}
}
public static void gererExceptions() throws FileSystemException {
try{
BEAN.leverExceptions();
}
catch(FileSystemException e){
BEAN.journaliser(e);
throw e;
}
catch(CharConversionException e){
BEAN.journaliser(e);
}
catch(IOException e){
}
}
public static class BeanSansEtat {
public void journaliser(Exception exception) {
System.out.println(exception.getMessage() + ", " + exception.getClass().getSimpleName());
}
public void leverExceptions() throws CharConversionException, FileSystemException, IOException {
int i = (int) (Math.random() * 3);
if (i == 0)
throw new CharConversionException();
if (i == 1)
throw new FileSystemException("");
if (i == 2)
throw new IOException();
}
}
}