Why do Java people frequently consume exceptions silently?

前端 未结 28 1621
傲寒
傲寒 2020-11-29 17:50

I never did any serious Java coding before, but I learned the syntax, libraries, and concepts based on my existing skills (Delphi & C#). One thing I hardly understand i

28条回答
  •  抹茶落季
    2020-11-29 18:14

    As others have pointed out, the reason you see this is for one of three reasons:

    1. An IDE generated the try-catch block
      • The code was copied and pasted
      • The developer put the stacktrace in to debug but never came back to handle the exception properly

    The last point is the least likely to occur. I say this because I don't think anyone really debugs this way. Stepping through code with a debugger is a much easier way to debug.

    The best description of what should be done in a catch block can be found in Chapter 9 of Effective Java by Joshua Bloch.

提交回复
热议问题