Catching an Exception from a called Method

前端 未结 4 684
情歌与酒
情歌与酒 2021-01-24 06:30

This is something that\'s been bugging me for a while with regards to Program Flow.

I wanted to know if it\'s possible to catch an error from a Method in order to stop i

4条回答
  •  情话喂你
    2021-01-24 07:07

    Can you try:

    try {
        method01()
    } catch (final Exception e) {
        // do something
        return; ///stop processing exit
    }
    

    the method01 will throw Exception:

    private void method01() throws Exception {
    // something
    }
    

提交回复
热议问题