Theory on error handling?

后端 未结 14 705
情歌与酒
情歌与酒 2021-01-29 18:28

Most advice concerning error handling boils down to a handful of tips and tricks (see this post for example). These hints are helpful but I think they don\'t answer all question

14条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-29 18:54

    I'm changing my design and coding philosophy so that:

    1. If all runs smoothly, as expected, no errors generated.
    2. Throw an exception if something different, or unexpected happens; let the caller handle it.
    3. If it can't be resolved, propagate it up a higher level.

    Hopefully, with this technique, the issues that get propagated to the User will be very important; otherwise the program tries to resolve them.

    I'm currently experiencing issues that get lost in the return codes; or new return codes are created.

提交回复
热议问题