-
Notifications
You must be signed in to change notification settings - Fork 201
Fix reload behaviors + Add OnLoadError event for file based config providers #497
Conversation
@divega ping for review |
@@ -32,6 +33,11 @@ public abstract class FileConfigurationSource : IConfigurationSource | |||
public bool ReloadOnChange { get; set; } | |||
|
|||
/// <summary> | |||
/// Will be called if an uncaught exception occurs in FileConfigurationProvider.Load. | |||
/// </summary> | |||
public Action<Exception> OnLoadError { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could consider making this a Func that returns bool to control whether we want to rethrow the exception. That might be a nice quality of life improvement, but not sure how useful it is always...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea, although not sure the meaning of returning true vs. false is clear. Maybe passing a "load error context" object that contains the exception, the sender (provider) and a bool to decide the outcome?
@divega updated adding the FileLoadErrorContext and renamed LoadError => LoadException as we discussed. |
SetFileLoadExceptionHandler |
@divega I don't think our CreateInstance/Build hack is going to work, as it is a breaking change. Lets say they derived from our current sources today and in their Build(), they all base.Build(), they will now get a NotImplemented exception since they didn't implement CreateInstance. I think we should just introduce a new method in FileConfigurationSource and call it in each of the Builds, its not the end of the world...
|
Updated with new IConfigurationBuilder.Get/SetFileLoadExceptionHandler sugar |
They can't. You get a compiler error if you try to call |
... anyway, I am not against what you did here. My only concern right now is the inconsistent naming between the Set/Get methods and the property on the file sources. |
I think we should consider renaming |
@divega @glennc updated PR with fixes to make reload behavior more reliable:
|
This PR now also fixes #486 |
Fixes #489
No sugar currently:
This at least enables some way to see what failures are occuring during load/reload
@divega