How to indicate that a method was unsuccessful

前端 未结 16 1548
走了就别回头了
走了就别回头了 2020-12-31 08:03

I have several similar methods, say eg. CalculatePoint(...) and CalculateListOfPoints(...). Occasionally, they may not succeed, and need to indicate this to the caller. For

16条回答
  •  暖寄归人
    2020-12-31 08:31

    I would say best practice is a return value means success, and an exception means failure.

    I see no reason in the examples you provided that you shouldn't be using exceptions in the event of a failure.

提交回复
热议问题