It is important when implementing error / exception handling in custom provider code that you handle your errors exceptionally elegantly as it is directly bound into vital security operations. When writing your exception code, it is important to take into consideration using the ProviderException class as opposed to throwing generalized exception, since the ProviderException class besides the obvious implication of throwing an exception when provider errors occurs, allow you to trap relevant errors related to your provider code that might not offer a pipe to pre-existing internal exception mechanisms.
You should consider using the ProviderException class for all sorts of exception handling for which the errors being introduced are specific to a configuration provider. This means for things such as connection strings, checking existence of arbitrary provider objects, and others.
For example, consider using the ProviderException class when checking if a role exists as this exception is related directly to the configuration provider.
foreach (string sRolename in sarrayRolenames)
throw new ProviderException(“The specified role name was not found in the role array.”);
Exception handling is important when working with configuration providers, so ensure that you are using the correct mechanisms to gracefully handle errors as they occur within your code.