Change unhandled exception auto-generated catch code in Eclipse?

前端 未结 4 714
终归单人心
终归单人心 2020-12-14 06:47

If I have unhandled exception in Java, Eclipse proposes two options to me: (1) add throws declaration and (2) surround with try/catch.

If I choose (2) it adds a code

4条回答
  •  春和景丽
    2020-12-14 07:26

    Yes, you can change the default code added by Eclipse.

    1. In Preferences, navigate to Java>Code Style>Code Templates.
    2. Under Code, select Catch block body.
    3. Press the Edit button to change the code. When finished, press the OK button.

    Consider adding a TODO comment in the default catch block. For example, the default includes:

         // ${todo} Auto-generated catch block
    

提交回复
热议问题