3 ms·
Having a function throwError makes me squirm. `isValid() || throwError()` is an abuse of abstraction
by gnarlouse 2y ago
Having a function throwError makes me squirm.
`isValid() || throwError()` is an abuse of abstraction
- t-writescode 2y agoA fail fast paradigm is a style of programming that can be used very effectively, as long as it's understood that's the style of code that is being written. Much of my code, for example, is fail fast, and then I have error handling, supervisors, etc, at a level that can log and restart the work.
- Izkata 2y agoNot in anything touching user or password validation. It's probably fairly safe the way it's used in this function, but I'd avoid it as a rule of thumb to not accidentally introduce some sort of timing attack. I'm a little disappointed no one mentioned this even as a side comment, since there's a whole section on doing short-circuit evaluation, even if it's not in a way that would cause this kind of problem.