Why do Java people frequently consume exceptions silently?

前端 未结 28 1688
傲寒
傲寒 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

    You should always forward it on or handle it suitably in a real-world context. A lot of articles and tutorials will simplify their code to get the more important points across though and one of the easiest things to simplify is error-handling (unless what you are doing is writing an article on error-handling that is :)). As java code will check for exception handling then putting a simple silent (or logging statement) catch block on is the simplest method to provide a working example.

    If you find this in anything other than example code, feel free to forward the code onto TDWTF, although they may have too many examples of it by now :)

提交回复
热议问题