3 ms·
Another idea, introduce ??? that would invoke on exception :) var something = (mayThrow() ??? (SomeException ex) => { log.Info(ex); return null} )
by jve 3y ago
Another idea, introduce ??? that would invoke on exception :)
var something = (mayThrow()
??? (SomeException ex) => { log.Info(ex); return null} )
??? (Exception ex) => { log.Fatal(ex); throw; };
Or maybe just start using Results as return type and get ValueOrDefault :) But when it comes to handling exceptions, I think it explodes there with ifs and processing IENumerables: https://github.com/altmann/FluentResults https://github.com/altmann/FluentResults
But then again, simpler Results wrapper may be used perhaps. But it is a different way of coding and takes some mental shift on how to think about errors and distinguish between error results and true exceptions.
Oh, csharplang already had discussion on the matters about try/catch single statements: https://github.com/dotnet/csharplang/issues/786 https://github.com/dotnet/csharplang/issues/786