vendredi 22 juillet 2016

Throw exception indicating variable name upon InvalidOperationException upon Nullable->Value

I have a large set of Nullable<> variables as input to a somewhat complex algorithm, some of which shouldn't be null in certain contexts. At the moment, I'm relying on the InvalidOperationException thrown upon Nullable<>.Value when I hit that wall. The client app of my algo thereby knows by that exception that something is missing, but doesn't know what.

I'm looking for a way to catch that exception and get back to the name of the variable that caused it (those variables have human-readable names), so my client app can get informed of it. I'm thinking Reflection is the only way, but where do I start ?





Aucun commentaire:

Enregistrer un commentaire