Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1210 from jnyrup/configurationStoreInterceptor
Intercept Reflection exceptions from `AppSettingsConfigurationStore`
- Loading branch information
Showing
2 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
Src/FluentAssertions/Common/ConfigurationStoreExceptionInterceptor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#if !NETSTANDARD1_3 && !NETSTANDARD1_6 | ||
|
||
namespace FluentAssertions.Common | ||
{ | ||
internal class ConfigurationStoreExceptionInterceptor : IConfigurationStore | ||
{ | ||
private bool underlyingStoreUnavailable; | ||
|
||
private readonly IConfigurationStore configurationStore; | ||
|
||
public ConfigurationStoreExceptionInterceptor(IConfigurationStore configurationStore) | ||
{ | ||
this.configurationStore = configurationStore; | ||
} | ||
|
||
public string GetSetting(string name) | ||
{ | ||
if (underlyingStoreUnavailable) | ||
{ | ||
return null; | ||
} | ||
|
||
try | ||
{ | ||
return configurationStore.GetSetting(name); | ||
} | ||
catch | ||
{ | ||
underlyingStoreUnavailable = true; | ||
return null; | ||
} | ||
} | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters