lundi 2 janvier 2023

Catch two exceptions and rethrow them [duplicate]

I want to catch two exceptions and log some stuff. Then the exception should thrown again. I get the following message: Unhandled exception type: IllegalAccessException

I tried out many constellations like using two catch blocks, check which class belong to the exception object (instanceof check) and so on. Everytime i get the mentioned above message....

List<Field> objectsList = getObjectList();
StringBuilder sb = new StringBuilder();
objectsList.forEach(a -> {
    try {
        a.setAccessible(true);
        sb.append(".....");
    } catch (IllegalArgumentException | IllegalAccessException e) {
        //Do some stuff
        throw e;
    }
});




Aucun commentaire:

Enregistrer un commentaire