samedi 9 juillet 2016

Find out what exceptions a method throws programmatically

Imagine you have a method like:

public void doGreatThings() throws CantDoGreatThingsException, RuntimeException {...}

Is there any way to programmatically get the declared thrown exceptions by way of reflection?

// It might return something like Exception[] thrownExceptions = [CantDoGreatThingsException.class, RuntimeException.class]





Aucun commentaire:

Enregistrer un commentaire