I'm building a custom content part that fetches its information from an external repository, mostly following the advice found @ How to change Orchard record repository and using a custom handler to fetch the data.
Working with external data stores opens up the possibility of all sorts of network exceptions, etc., which would cause the underlying record not be saved. However, if there's an exception thrown in the ContentHandler
, it's swallowed up by the Invoke<TEvents>
method so that (unless it's a "fatal" exception) the user wouldn't know about the exception and would be notified by the AdminController
that "Your {0} has been saved."
, when in fact it hasn't been.
A workaround that's obvious to me is to intercept the error somehow and notify the content driver for my content part, which exposes the executing AdminController
. At that point, I can hook into the controller's ModelState
and introduce an error, which would then be caught and then I'd be notified of an error without any false positive notifications.
Are there any other extensibility points available in Orchard that would handle this kind of external access better than altering the controller's ModelState
via a content driver?