fix(plugin-workflow): track error when instruction not exist (#5319)

This commit is contained in:
Junyi 2024-09-25 18:25:57 +08:00 committed by GitHub
parent 06af42da5b
commit d335ffee7f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -206,6 +206,9 @@ export default class Processor {
public async run(node, input?) {
const { instructions } = this.options.plugin;
const instruction = instructions.get(node.type);
if (!instruction) {
return Promise.reject(new Error(`instruction [${node.type}] not found for node (#${node.id})`));
}
if (typeof instruction.run !== 'function') {
return Promise.reject(new Error('`run` should be implemented for customized execution of the node'));
}
@ -232,6 +235,9 @@ export default class Processor {
private async recall(node, job) {
const { instructions } = this.options.plugin;
const instruction = instructions.get(node.type);
if (!instruction) {
return Promise.reject(new Error(`instruction [${node.type}] not found for node (#${node.id})`));
}
if (typeof instruction.resume !== 'function') {
return Promise.reject(
new Error(`"resume" method should be implemented for [${node.type}] instruction of node (#${node.id})`),