
{filelink=4353}
import java.io.*;
public class GestionExceptions {
void throwRuntimeException(int type) {
try {
switch(type) {
case 0: throw new FileNotFoundException();
case 1: throw new IOException();
case 2: throw new RuntimeException();
default: return;
}
} catch(Exception e) {
throw new RuntimeException(e);
}
}
}
class MesExceptions extends Exception {
public static void main(String[] args) {
GestionExceptions gexec = new GestionExceptions();
gexec.throwRuntimeException(3);
for(int i = 0; i < 4; i++)
try {
if(i < 3)
gexec.throwRuntimeException(i);
else
throw new MesExceptions();
} catch(MesExceptions e) {
System.out.println("Mes Exceptions: " + e);
} catch(RuntimeException re) {
try {
throw re.getCause();
} catch(FileNotFoundException e) {
System.out.println(
"FileNotFoundException: " + e);
} catch(IOException e) {
System.out.println("IOException: " + e);
} catch(Throwable e) {
System.out.println("Throwable: " + e);
}
}
}
}