What should be the best Exception Handling Strategy

后端 未结 7 2040
逝去的感伤
逝去的感伤 2021-02-14 07:28

I am working on application where user invokes a method from UI , on this I am calling a method from business class which calls another methods

UI--> Method1 -->Method2

7条回答
  •  北荒
    北荒 (楼主)
    2021-02-14 08:11

    It almost always pays to separate exception handling and error reporting.

    Catch exceptions where it makes sense to catch them, where you have enough context to know what exactly happened and how to recover - inside Method1..3. On catching known exception, push a record to the error log.

    After completing operation or step UI level can check error log and present message of "Following errors occurred: ...".

提交回复
热议问题