r/programminghorror • u/Daeben72 • Jun 05 '26
C# SuccessMessage ErrorMessage
ErrorMessage successMessage = new ErrorMessage(ErrorType.ActivityCreateSuccess);
(From an approved PR with 2 reviewers - how do some people sleep at night??)
230
Upvotes
View all comments
Show parent comment
9
u/LordTurson Jun 05 '26
I really like how functional languages (and Rust) do this as the only real way of error handling available. If you do something that can fail, you must expect a
Result, which can be eitherOkwith the computation result, or anErrwith the error information - never both, never in a mixed half-and-half state, and must always be handled or it will emit a compile error.In fact I like it so much, I wrote myself a small Python library that does just that (as much as it's humanly possible with the limitations of modern Python)!