16

GodDAMN, C# 7.0 is so ridiculously feature packed. I can pattern-match inside a predicate on an exception filter. Want to catch ONLY NHibernate's exceptions caused by a SQL timeout? Boom:

catch (GenericADOException adoEx) when (adoEx.InnerException is SqlException sqlEx && sqlEx.Number == -2) { return Failure("timeout"); }

Comments
Add Comment