Skip to content

Commit

Permalink
fix(error handling): deal with unexpected errors globally ensuring as…
Browse files Browse the repository at this point in the history
…ync ops finish
  • Loading branch information
botzai committed Feb 18, 2025
1 parent 9b791f9 commit 2292d4d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/core/configManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ export class ConfigManager {
public static async getConfig(params: GetConfigParams): Promise<ExecutionConfig> {
const { archetype = options.archetype, logPrefix } = params;
if (!ConfigManager.configs[archetype]) {
ConfigManager.configs[archetype] = await ConfigManager.initialize({ archetype, logPrefix });
ConfigManager.configs[archetype] = await ConfigManager.initialize({ archetype, logPrefix }).catch(error => {
logger.error(error, `Error initializing config for archetype: ${archetype}`);
throw error;
});
}
return ConfigManager.configs[archetype];
}
Expand Down Expand Up @@ -76,7 +79,7 @@ export class ConfigManager {
logger.info(`Successfully loaded extension: ${moduleName}`);
} catch (error) {
logger.error(`Failed to load extension ${moduleName} from all locations: ${error}`);
if (process.env.NODE_ENV !== 'test') process.exit(1);
throw new Error(`Failed to load extension ${moduleName} from all locations: ${error}`);
}
}
}
Expand All @@ -90,7 +93,10 @@ export class ConfigManager {
if (logPrefix) setLogPrefix(logPrefix);

// Load plugins during initialization
await this.loadPlugins(options.extensions);
await this.loadPlugins(options.extensions).catch(error => {
logger.error(error, `Error loading plugins`);
throw error;
});
logger.info(`Initializing config manager for archetype: ${archetype}`);
logger.debug(`Initialize params: ${JSON.stringify(params)}`);

Expand Down

0 comments on commit 2292d4d

Please sign in to comment.