Skip to content

Commit 1302188

Browse files
committed
Enhance lifecycle rules loading with error handling and logging
1 parent 58422bf commit 1302188

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/management/lifecycle/lifecycle.service.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,19 @@ export class LifecycleService extends AbstractServiceSchema implements OnApplica
224224
* It logs the process of loading and validating each file, and handles any errors that occur during file reading or validation.
225225
*/
226226
private async loadLifecycleRules(): Promise<ConfigObjectSchemaDTO[]> {
227+
let files: string[] = [];
228+
227229
const lifecycleRules: ConfigObjectSchemaDTO[] = [];
228230
this.logger.verbose('Loading lifecycle rules from configuration files...');
231+
this.logger.verbose('Initializing LifecycleService...');
232+
233+
try {
234+
files = readdirSync(`${process.cwd()}/configs/lifecycle`);
235+
} catch (error) {
236+
this.logger.error('Error reading lifecycle files', error.message, error.stack);
237+
}
229238

230-
for (const file of readdirSync(`${process.cwd()}/configs/lifecycle`)) {
239+
for (const file of files) {
231240
let schema: ConfigObjectSchemaDTO;
232241
if (!file.endsWith('.yml') && !file.endsWith('.yaml')) {
233242
this.logger.warn(`Skipping non-YAML file: ${file}`);

0 commit comments

Comments
 (0)