Today i have come across a bug where the application starts throwing multiple exceptions(multiple messagebox). The Application uses DispatcherUnhandledException.
While investigating i've found that the converter used to format the date and time in the dataGrid throws the FormatException if the parameter to the converter is NULL.
Is it advisable to throw exception from the Converter in any case?
According to MSDN, no:
The data binding engine does not catch exceptions that are thrown by a user-supplied converter. Any exception that is thrown by the Convert method, or any uncaught exceptions that are thrown by methods that the Convert method calls, are treated as run-time errors. Handle anticipated problems by returning DependencyProperty.UnsetValue.
That being said, personally I use the NotSupportedException
when either the Convert
or ConvertBack
method is not supported.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With