I can't see why the 4 first conditions aren't met. I didn't change the name of the methods nor anything else. There is no BEAN.log, but a BEAN.protokollieren and also no BEAN.throwExceptions but a BEAN.ausnahmenAusloesen. Maybe i didn't get the task right.
I would appreciate if someone could point me in the right direction.
package de.codegym.task.task09.task0915;
import java.io.CharConversionException;
import java.io.IOException;
import java.nio.file.FileSystemException;
/*
Benutzerdefinierte Ausnahmen abfangen
*/
public class Solution {
public static StatelessBean BEAN = new StatelessBean();
public static void main(String[] args) {
try {
ausnahmenBehandeln();
} catch ( FileSystemException e) {
BEAN.protokollieren(e);
}
}
public static void ausnahmenBehandeln() throws FileSystemException {
try {
BEAN.ausnahmenAusloesen();
} catch ( FileSystemException e) {
BEAN.protokollieren(e);
throw e;
} catch ( CharConversionException e ) {
BEAN.protokollieren(e);
} catch ( IOException e ) {
BEAN.protokollieren(e);
}
}
public static class StatelessBean {
public void protokollieren(Exception ausnahme) {
System.out.println(ausnahme.getMessage() + ", " + ausnahme.getClass().getSimpleName());
}
public void ausnahmenAusloesen() 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();
}
}
}