Hacker News new | past | comments | ask | show | jobs | submit login

Or, worse, and common in classic VB, ON ERROR RESUME NEXT. Which just skips the line that errored.



It sets Err. Which is essentially how SH, C and Go work too.

(With the obvious exceptions of longjmp and panic/defer, global vs local var, and Go forcing to assign the error.)

On Error Resume Next isn't great, but calling it much worse than On Error Goto, or much worse than other languages, is a stretch.

My point is only that people complain about it in VB disproportionally often compared to other languages. (Does that mitigate the issue to some extent, if every VB dev is super aware of it?)


I don’t think I’ve ever seen any vb code which actually checks that, though,or dry little, certainly. In C and Go you get something returned, which is a hint that you should maybe do something with it. In VB a magic global variable is set, and then generally ignored.


That's how I've done it. Enable it before the line(s) in question, then check err.number, and add "On Error Goto 0" after that so you get the default handler again.

Usually much cleaner than jumping to somewhere else, but that had its uses too.


Ah. I was never actually a VB programmer, but I did have a few side-jobs porting VB apps (mostly CRUD webapps) to something more modern in the mid-noughties. My experience from that was that real world use of on error resume next was to turn it on and leave it on.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: