dimanche 24 juillet 2016

Why one should try throw unchecked exception over checked exception?

I've been told that I should consider throwing Unchecked exception over Checked exception in my code and not only that, but to extend the RuntimeException with my own one. Now, I do understand the difference between the two, but still doesn't understand why should I do that?

If I have this method header which throws 2 kinds of exceptions:

public static Optional<String> getFileMd5(String filePath) throws NoSuchAlgorithmException, IOException {}

Why should I replace them with one (less detailed) exception?

Aucun commentaire:

Enregistrer un commentaire