Comments (4)
If we put an exception handler on the ConfigurationBuilder calls, we can catch the initial parsing exceptions, but I haven't been able to figure out how to avoid a downstream NullReferenceException yet.
private void SetConfigRoot()
{
var b = new ConfigurationBuilder().SetBasePath(AppDomain.CurrentDomain.BaseDirectory);
b.AddYamlFile("app.config.yaml", true);
b.AddJsonFile("app.config.json", true);
b.SetFileLoadExceptionHandler((fleContext) =>
{
// This is hit whenever a config file is present but empty (or entirely comments).
// Ideally, we would load defaults for an emtpy file and present a warning/error for bad JSON/YAML syntax.
Resolver.Log.Error($"Error loading file configuration:: {fleContext.Exception}");
this.ConfigurationRoot = null; // Still blows up later in "[External Code]"!
});
this.ConfigurationRoot = b.Build();
}
Error message:
System.NullReferenceException
Message=Object reference not set to an instance of an object.
from meadow.core.
Since app.config.* is a weird case, allowing JSON or YAML, I tried an empty YAML file with a populated JSON file.
Oddly, this doesn't appear to fail at all, and it grabs the config from the second JSON source just fine (due to order of adding file providers).
from meadow.core.
Even more strange. The reverse is not true. If you have a YAML file full of settings and an empty JSON file, it will still throw an exception and hit the SetFileLoadExceptionHandler
action.
from meadow.core.
Should be addressed by #187.
from meadow.core.
Related Issues (20)
- Add package descriptions in the csproj HOT 1
- Update App instantiation
- WifiAdapter.Scan should return `IList<Network>` and be `async` HOT 3
- SpiClockConfiguration takes a long for speed HOT 1
- Review V2 pinouts HOT 2
- Unitize IPwm HOT 2
- Unexpected InterruptGroupInUseException HOT 4
- GetPortAndPin is returning an interrupt group but value is labelled pin
- App settings: restart log message not reflecting application settings? HOT 2
- App settings: JSON/YAML settings not affecting app? HOT 4
- Test Issue HOT 1
- MQTT Connection to Broker fails
- Add SD Card support to Update Service
- Validate ProjLab v3 RS485 HOT 1
- Complete NotImplemented items in Meadow.Linux
- Complete NotImplemented items in Meadow.Windows
- Move file system bits over to PlatformOS
- The RS232 interface does not work properly HOT 2
- Add Cell Scanner
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from meadow.core.