1
lopu
1y

Javascript should have try blocks without the need for catch or finally....... IMO

Comments
  • 11
    Why?

    Having literally a “ignore errors” syntax just invites even worse code.

    You can still do it with an empty catch but then its at least a bit more obvious your doing it.

    Even when its relevant I would still want the catch to have some comment on why you have no error handling.
  • 0
    What for?
  • 0
    Just when debugging it's annoying when debugging SSR react apps having to add a catch block when you're just debugging window usages
  • 0
    And if you use eslint you have to add // ignore or nothing as a comment in the catch block just to stop the empty block error..
  • 0
    Kotlin library like ArrowJS could be what you're looking for, maybe sth like that exists in JavaScript, too?

    https://arrow-kt.io/learn/...
  • 6
    @lopu and that is a good thing.

    Old vbscript had an “on error resume” statement that just ignored errors and it was a dumpster fire solution resulting in so many invisible problems.

    Forcing you to be explicit with ignoring is good.

    Also? That empty catch, is a good place for a break point :)

    Having used js since its inception back in netscape 2 I see no reason to make it easier to ignore errors, I would even want it to enforce a real statement in the catch making it even more annoying to ignore errors.
  • 0
    Dumb take.
  • 1
    yes please.

    This language is a shitshow already, just mess it up more, until it's unusable.

    Don't forget to also throw in goto and make whitespaces optional.
  • 0
    Just don’t wrap your code in a try block
  • 2
    that's the mentality why we have shit code.
  • 0
    It does!!

    They are used by default, so you don't even have to write `try {alert();}` - instead you can write a shorthand: `alert()`
  • 0
    @netikras are you serious?
  • 2
    @iiii forgot the /s
Add Comment