This is a discussion on Python’s forums about adding something akin to a throws keyword in python.

  • Fal@yiffit.net
    link
    fedilink
    English
    arrow-up
    2
    arrow-down
    8
    ·
    1 year ago

    It was always quite clear which exceptions I had to catch (or not)

    Lol. You’re literally the only one that likes checked exceptions. And, it seems you think that it actually gives you information about what exceptions to catch. It does not. Most things just catch and rethrow as a RuntimException

    • qwertyasdef@programming.dev
      link
      fedilink
      arrow-up
      7
      ·
      1 year ago

      Hey, I like checked exceptions too! I honestly think it’s one of Javas’s best features but it’s hindered by the fact that try-catch is so verbose, libraries aren’t always sensible about what exceptions they throw, and methods aren’t exception-polymorphic for stuff like the Stream API. Which is to say, checked exceptions are a pain but that’s the fault of the rest of the language around them and not the checked exceptions per se.

    • CodeMonkey@programming.dev
      link
      fedilink
      arrow-up
      6
      ·
      1 year ago

      I also like checked exceptions. I like having a compile time check that I thought through error scenarios.

      Is it perfect? No, but it should be iterated upon, not discarded.

      FYI, catching and rethrowing as an unchecked exception is a pretty bad anti-patern (and a foul code smell).