Skip to content

Commit bdbcea3

Browse files
m-courtinLeeyoungone
authored andcommitted
fix: fixes issue 1444 invoking the onPluginInit
In api server the instantiatePlugin function is now calling the required onPluginInit for each corresponding connector Closes: hyperledger-cacti#1444 Signed-off-by: Michael Courtin <[email protected]>
1 parent a2a391e commit bdbcea3

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

packages/cactus-cmd-api-server/src/main/typescript/api-server.ts

+20
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,26 @@ export class ApiServer {
342342
const pluginFactory = await createPluginFactory(pluginFactoryOptions);
343343

344344
const plugin = await pluginFactory.create(pluginOptions);
345+
346+
// need to invoke the i-cactus-plugin onPluginInit functionality here before plugin registry can be used further
347+
try {
348+
await plugin.onPluginInit();
349+
} catch (error) {
350+
const fnTag = `${this.className}#instantiatePlugin`;
351+
const packageName = plugin.getPackageName();
352+
const instanceId = plugin.getInstanceId();
353+
354+
const errorMessage = `${fnTag} failed calling onPluginInit() on the plugin '${packageName}' with the instanceId '${instanceId}'`;
355+
356+
this.log.error(errorMessage, error);
357+
358+
if (error instanceof Error) {
359+
throw new RuntimeError(errorMessage, error);
360+
} else {
361+
throw new RuntimeError(errorMessage, JSON.stringify(error));
362+
}
363+
}
364+
345365
return plugin;
346366
}
347367

0 commit comments

Comments
 (0)