by kaapipo · 1y ago · 0 comments
Today I write C# at my job and I could not be happier with the usage of exceptions.
> Exceptions and panics can still creep so it's not even "safer"
This part is just as true for checked exceptions - you still have unchecked exceptions too. Ultimately you can't get away from needing a way to bail out from unrecoverable states. But "secondary state that is recoverable and understandable, but should be handled off the primary codepath" is a very useful tool to have in your vocabulary.
> Today I write C# at my job and I could not be happier with the usage of exceptions.
How do you do e.g. input validation? Things that are going to be 4xx errors not 5xx errors, in HTTP terms. Do you use exceptions for those? (I note that C# doesn't have checked exceptions at all, so there's no direct equivalent)
One should be cautious every time it feels like there is an obviously right way to do something that everybody fails to see :)
What? No you don't. You can just propagate up the errors you can't handle with the types they come with.