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

Commit 05e4a49

Browse files
committed
Throw a consistent exception when the ProviderElement's factory cannot b initialized. Fixes #151
1 parent 2791c02 commit 05e4a49

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

Enyim.Caching/Configuration/ProviderElement.cs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,17 @@ public T CreateInstance()
7070
var type = this.Factory;
7171
if (type != null)
7272
{
73-
this.factoryInstance = (IProviderFactory<T>)FastActivator.Create(type);
74-
this.factoryInstance.Initialize(this.parameters);
73+
try
74+
{
75+
var instance = (IProviderFactory<T>)FastActivator.Create(type);
76+
instance.Initialize(this.parameters);
77+
78+
this.factoryInstance = instance;
79+
}
80+
catch (Exception e)
81+
{
82+
throw new InvalidOperationException(String.Format("Could not initialize the provider factory {0}. Check the InnerException for details.", type), e);
83+
}
7584
}
7685
}
7786

@@ -109,20 +118,20 @@ protected override void PostDeserialize()
109118

110119
#region [ License information ]
111120
/* ************************************************************
112-
*
121+
*
113122
* Copyright (c) 2010 Attila Kiskó, enyim.com
114-
*
123+
*
115124
* Licensed under the Apache License, Version 2.0 (the "License");
116125
* you may not use this file except in compliance with the License.
117126
* You may obtain a copy of the License at
118-
*
127+
*
119128
* http://www.apache.org/licenses/LICENSE-2.0
120-
*
129+
*
121130
* Unless required by applicable law or agreed to in writing, software
122131
* distributed under the License is distributed on an "AS IS" BASIS,
123132
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
124133
* See the License for the specific language governing permissions and
125134
* limitations under the License.
126-
*
135+
*
127136
* ************************************************************/
128137
#endregion

0 commit comments

Comments
 (0)