Additionally to Lars's answer, raising an error can indeed simply be done by throw new Exception()
, there are no custom exceptions available in the ECL API that you can use.
I would use the override Exception(message, innerException)
if you have an Exception available, and for the message you could use a resource, like I have done here in the class implementing the IContentLibrary
interface:
public void Initialize(string mountPointId, string configurationXmlElement, IHostServices hostServices)
{
try
{
// do something to initialize your provider
// like reading the mountpoint configuration
}
catch (Exception e)
{
// just raise the error with a readable message
throw new Exception(string.Format(Resources.ConfigurationError, mountPointId), e);
}
}
But as Lars mentions, I have to agree it would probably be nicer to do this check in your class which implements the IContentLibraryContext
interface.
But keep in mind, while it is nice to show a visual indication to a user that the connection cannot be made for some reason, not everything has a use for this visual representation. When the publisher is trying to render an ECL item, it needs an error to halt the publishing process.