Elektrine lite

← Feed

@arndissler@hachyderm.io

Post #2522657

2025-06-30 08:06 UTC

@muhdiekuh@ruhr.social Did you mean catch(e: SomeError) {}? It's a little bit unhandy in comparison to other languages/dialects, that JS/TS does not allow to specify the error type and you need to boil them down on your own (w/ instanceof), but once you find your way to write clean try-catch-blocks it's not a big issue. For larger, collaborative projects, one should define project-wide rule how to handle errors properly, otherwise the code is getting messy as everyone have their own strategy to handle errors what makes it quite hard to catch up after a couple of month'.

Replies (1)

  • @muhdiekuh@ruhr.social 2025-07-16 06:41

    @arndissler@hachyderm.io Yes, this is exactly what I meant, sorry clippy :D The problem with catching + instanceof is that the stack trace is not "correct" anymore. Yes, this is something one can deal with, but you need to take care of it, which means people will forget it and then you're doomed. Do you know of any public linting rules that enforce consistent error handling behaviour?

    Open ##2522658