• chrismit3s@feddit.de
    link
    fedilink
    arrow-up
    1
    ·
    8 months ago

    If you wrote the type signature of get_user as tuple[User, None] | tuple[None, Exception], the assertion would not be necessary and the type checker wouldn’t complain.

  • CodeMonkey@programming.dev
    link
    fedilink
    arrow-up
    1
    ·
    8 months ago

    They forgot the Erlang approach: throw exceptions but never catch them. If you are throwing an exception either your code is wrong or your system is bad. In either case, you should crash violently and let another instance handle the retry.