Skip to content
This repository has been archived by the owner on Jul 7, 2019. It is now read-only.

Commit

Permalink
Throw a consistent exception when the ProviderElement's factory canno…
Browse files Browse the repository at this point in the history
…t b initialized. Fixes #151
  • Loading branch information
enyim committed Aug 18, 2016
1 parent 2791c02 commit 05e4a49
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions Enyim.Caching/Configuration/ProviderElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

Expand Down Expand Up @@ -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.