Permalink
Browse files

Throw a consistent exception when the ProviderElement's factory canno…

…t b initialized. Fixes #151
  • Loading branch information...
1 parent 2791c02 commit 05e4a491fbfea609b5ed5c6eadefad402c34e7ea @enyim committed Aug 18, 2016
Showing with 16 additions and 7 deletions.
  1. +16 −7 Enyim.Caching/Configuration/ProviderElement.cs
@@ -70,8 +70,17 @@ public T CreateInstance()
var type = this.Factory;
if (type != null)
{
- this.factoryInstance = (IProviderFactory<T>)FastActivator.Create(type);
- this.factoryInstance.Initialize(this.parameters);
+ try
+ {
+ var instance = (IProviderFactory<T>)FastActivator.Create(type);
+ instance.Initialize(this.parameters);
+
+ this.factoryInstance = instance;
+ }
+ catch (Exception e)
+ {
+ throw new InvalidOperationException(String.Format("Could not initialize the provider factory {0}. Check the InnerException for details.", type), e);
+ }
}
}
@@ -109,20 +118,20 @@ protected override void PostDeserialize()
#region [ License information ]
/* ************************************************************
- *
+ *
* Copyright (c) 2010 Attila Kiskó, enyim.com
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* ************************************************************/
#endregion

0 comments on commit 05e4a49

Please sign in to comment.