@@ -25,7 +25,6 @@ export default class FileDataInitializerFDv2 implements subsystemCommon.DataSour
2525 private _yamlParser ?: ( data : string ) => any ;
2626 private _fileLoader ?: FileLoader ;
2727
28- // TODO: do a options check here
2928 constructor ( config : Configuration , platform : Platform ) {
3029 const options = config . dataSystem ?. dataSource ?. initializerOptions as FileDataInitializerOptions ;
3130 this . _validateInputs ( options , platform ) ;
@@ -78,17 +77,15 @@ export default class FileDataInitializerFDv2 implements subsystemCommon.DataSour
7877 this . _paths ,
7978 false , // autoupdate is always false for initializer
8079 ( results : { path : string ; data : string } [ ] ) => {
81- // Whenever changes are detected we re-process all of the data.
82- // The FileLoader will have handled debouncing for us.
8380 try {
8481 const parsedData = this . _processFileData ( results ) ;
8582
86- statusCallback ( subsystemCommon . DataSourceState . Valid ) ;
87-
8883 payloadProcessor . addPayloadListener ( ( payload ) => {
8984 dataCallback ( payload . basis , { initMetadata, payload } ) ;
9085 } ) ;
9186
87+ statusCallback ( subsystemCommon . DataSourceState . Valid ) ;
88+
9289 payloadProcessor . processEvents ( parsedData . events ) ;
9390
9491 statusCallback ( subsystemCommon . DataSourceState . Closed ) ;
@@ -102,7 +99,16 @@ export default class FileDataInitializerFDv2 implements subsystemCommon.DataSour
10299 } ,
103100 ) ;
104101
105- this . _fileLoader . loadAndWatch ( ) ;
102+ this . _fileLoader . loadAndWatch ( ) . catch ( ( err ) => {
103+ this . _logger ?. error ( 'Error loading files' , err ) ;
104+ statusCallback (
105+ subsystemCommon . DataSourceState . Closed ,
106+ new LDPollingError (
107+ DataSourceErrorKind . NetworkError ,
108+ `Failed to load files: ${ err instanceof Error ? err . message : String ( err ) } ` ,
109+ ) ,
110+ ) ;
111+ } ) ;
106112 }
107113
108114 private _processFileData ( results : { path : string ; data : string } [ ] ) {
0 commit comments