• henfredemars@infosec.pub
      link
      fedilink
      English
      arrow-up
      1
      ·
      3 hours ago

      The best part is there’s already a default error handler! If the program dies, you know there was an error.

  • flamingo_pinyata@sopuli.xyz
    link
    fedilink
    arrow-up
    11
    ·
    11 hours ago

    Or just code the happy path and let it crash.

    (this is actually a real philosophy in the Erlang world and I’m bummed it doesn’t receive wider acceptance)

    • TootSweet@lemmy.world
      link
      fedilink
      English
      arrow-up
      8
      ·
      edit-2
      8 hours ago

      I can definitely see a lot of good applications for this way of doing things.

      It does seem like I often run across “error handling” code that literally just catches a bunch of different exception types and throws a new exception with the same content from the caught error just reworded, adding literally zero helpful information in the process.

      It’s definitely the case that sometimes the exact sort of crash you’d get if you didn’t handle errors is exactly the best sort of exception output the program could do given its particular use case and target audience. Or at least it might be best to let the error be handled much further away in the call stack.

      • Dultas@lemmy.world
        link
        fedilink
        arrow-up
        4
        ·
        6 hours ago

        I’ve seen a lot worse where they just gobble the original error and throw a new one with 0 of the original context included making it 100x more difficult to debug.

  • over_clox@lemmy.world
    link
    fedilink
    arrow-up
    5
    ·
    edit-2
    10 hours ago

    Me while doing error handling?

    Well shit, all my functions both take and return memory addresses. When one of those blocks of data happen to fail the data sanity check, the function returns either -1, -2, -3, -4.

    See, you’ll never get such numbers as proper memory addresses, they’re assigned as blocks, larger than 4 bytes…

    So, if one of my functions returns a -1 through -4, that tells me which argument to the function failed the sanity check…