Error Handling
Prism 9 introduced better Error Handling for all Commands including the AsyncDelegateCommand. This provides several useful opportunities for app developers.
- Avoid needing to wrap every method in a
try/catch
. - Provide multiple handlers to provide specific logic based on the type of Exception encountered.
- Share error handling logic across multiple commands.
new DelegateCommand(() => { })
.Catch<NullReferenceException>(nullReferenceException => {
// Provide specific handling for the specified Exception Type
})
.Catch(exception => {
// Handle any exception thrown
})