THIS Is How You Should Handle Recoverable Errors!

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 พ.ย. 2024

ความคิดเห็น • 5

  • @MaNgAnlmE
    @MaNgAnlmE 6 หลายเดือนก่อน +3

    I like to think about exceptions like this: “Exceptions are only to communicate with developers(or more generally maintainers of the application) NOT users” Do you think that’s a good rule?

    • @AboutCleanCode
      @AboutCleanCode  6 หลายเดือนก่อน +2

      @MaNgAnlmE I think this is a quite good guideline 👍

    • @pl4gueis
      @pl4gueis 5 หลายเดือนก่อน

      I see exceptions more for unexpected errors that we can't possible can recover from like hardware failures that prevent the application from functioning. All errors that we can possibly recover from by retrying or letting the user decide are better treated like part of the result and communicated in the function signature.

  • @Zeero3846
    @Zeero3846 2 หลายเดือนก่อน

    Result types are just preparing you to eventually distinguish between HTTP status codes for whenever your application gains a web API. You might as well start with them and avoid exceptions altogether.
    Also, every time you think you could use null as a value, just stop. You're probably wrong. If it's a stand-in for an empty string or zero, just use those values to begin with. You can avoid a lot of null checks that way. Unexpected nulls are always exceptional. The only exception is when you have to interface with someone else's code that doesn't follow this rule, forcing you to handle null like a definite value.

    • @AboutCleanCode
      @AboutCleanCode  2 หลายเดือนก่อน

      Looking at languages like F# and Rust I think result types have much more potential