6
shekyb
1y

horror story in two lines

```
} catch (e) {
console.log(e)
}
```

Comments
  • 1
    One letter variable names 😱
  • 0
    macro_rules! assume {
    ($r:tt) => {
    $r.unwrap_or_else(|e| eprintln!("{e:?}"));
    }
    }

    In case anyone missed this antipattern from Rust
  • 0
    I have entirely too many macros. I have one for mapping shared enum values, specifically for use in a match statement. I have a macro that's just Option::unwrap_or but with support for control flow commands such as continue or return in the null path.
  • 1
    @Lensflare it is ok in this context. Rust uses single letter when there is only one error also
  • 4
    When did I give you access to my source code?
  • 0
    @Lensflare e for error is pretty much a staple at this point tho
  • 2
    @darksideofyay I don‘t know about JS but it‘s still considered bad practice in the languages that I know.

    And I agree: Doesn‘t matter if it‘s common and known by most devs, it‘s still bad imo. Just use "error". It‘s not that long.
  • 5
    @Lensflare sure, I'm just saying it's still readable, so I'm not that offended by it. to me e for error is like i for iteration, it's very commonplace
  • 2
    @Lensflare Even if we say that "e" is a bad name, why would "error" be any better? This is an argument to a catch block, so the fact that it is an error is already evident. Just putting more characters in the name isn't going to improve readability. If we wanted to give it a better name, it should refer to what the error indicates and most likely take the form of a past perfect verb such as "buzzed" or "eBuzzed" (because JS is a dynamically typed language so JS devs often rely on variants of hungarian notation to couple type information to variables somehow).
  • 2
    @lbfalvy you got a point there. But in the case that the error is really generic, "error" is fine.
  • 1
    that's three lines.
  • 1
    @Lensflare I think that if error is fine then so is e, all readers who know how to code even just a little bit associate e to error instantly.
  • 3
    @lbfalvy I disagree. I’ve seen e also being used for "event".
    It may be true for JS, though.
  • 1
    @Lensflare That's a great point, I'll take note and I suggest "err"
  • 0
    @Lensflare "ev" is more common for events, but the ambiguity exists nonetheless so you convinced me that "e" should not be used.
  • 1
    @Lensflare especially in a Result<Event, Error> this will confuse the hell out of you, if suddenly both matches provide e.

    And especially in a language like rust, you should be clear about intent.
  • 0
    @darksideofyay my greavence is more with silent catch
  • 0
    What is the horror here?
Add Comment