dimanche 20 novembre 2016

how to deal with exceptions for every method in a class

I hava a class, i need add try catch for every method, but it looks redundant, so i need a good way to fix it, what kind of design pattern can solve this?

public class Test {
    public void a() {
        try {
            do something;
        } catch (Exception e) {
            logger.error("error happened");
        }
    }

    public void b() {
        try {
            do something;
        } catch (Exception e) {
            logger.error("error happened");
        }
    }
}

Aucun commentaire:

Enregistrer un commentaire