Hacker News new | ask | show | jobs
by whoisthemachine 1342 days ago
I agree, `UnreachableException` is really poorly used here, and most of these are argument exceptions, and clearly are reachable. However, for other "unexpected behaviors", you should really throw an `InvalidOperationException` - you did something that is invalid. And even better if you sub-class Invalid with a custom exception that more clearly describes the unexpected behavior (also easier to search for that exception type in your log analysis tool).

[0] https://learn.microsoft.com/en-us/dotnet/api/system.invalido...