I'm currently having an issue with a 3rd party control library provider. They have an exception occulting culture that gets in the way of my general fail-fast approach when developing software.
An example: their grid control proposes a
RowValidating event in which it's possible to check user data input before it's committed to the underlying object. The event argument has a
IsValid boolean property and an
ErrorText string property. If the handler had the
IsValid property set to
False, the grid will treat the row as invalid, present the error text followed by "Do you want to correct the value?" in a yes / no dialog box.
The problem is that if the handler throws an actual
Exception during the validation process, the grid catches it and will behave exactly like described above - only it will use the caught exception's
Message property as the validation error text. The exception instance, even though it's actually MY code that caused it, can't ever be caught afterwards. There's no way for me to handle it other than wrapping my validation code in a try/catch block that catches everything.
Of course I don't want my code to throw any exceptions, but hey... errare humanum est! If that ever happens, I'd much prefer having the app crash and burn than hiding the exception away! For these scenarios I have a global handler that will log the unhandled exception right before the app crashes. This is where I'd expect any of them to end up.
Since my company made a huge investment in this particular 3rd party provider (both from learning and actual code running with it), I can't just run to another vendor - much less making my own grid control.
I tried talking to the vendor so that this gets fixed but they won't do anything in fear of causing breaking changes for other customers (understandable). They also won't introduce any kind of boolean flag to circumvent the behavior (less understandable).
Right now I'm uncomfortable deploying an app in which I know there's a chance for it to run in a corrupted state. I also hate having to wrap my event code in a try/catch block that may encounter an
Exception from which it's impossible to gracefully recover from.
What kind of solution can I use to prevent or fix this problem?
TL;DR: 3rd party vendor takes away
Exception instances thrown from my own code, workarounds are ugly and unsatisfying, don't know what to do with this.