Open lxe opened 9 years ago
I guess I can register on error
event, but this just undoes the synchronous nature of config initialization.
As mentioned; errors need to throw async because production. There are examples on how to write the tests.
errors need to throw async because production.
I agree that If an error occurs during runtime, after the things are configured, it should of course log. If config is not initialized with all the required parameters, the process should crash.
Things that are synchronous should stay synchronous. If async operations are being performed in the background, it should do zeroConfig(..., function onConfigLoad(err, config) { ... });
. Or, following the existing EE pattern: zeroConfig.on('load', function onConfigLoad(err, config) { ... })
Why do other things throw in this case? Like:
https://github.com/uber/zero-config/blob/master/index.js#L15
Because one is a programmer error and one is an operational error.
The programmer errors are thrown and the operational errors are emitted with the standard node event emitter interface
https://github.com/uber/zero-config/blob/master/index.js#L30-L34
All config loading is synchrnonous.
fetchConfig()
returns a result, and THEN throws an error, which is undesirable and confusing. For example:^ This tests will fail, and THEN the test suite will crash.