Skip to content

Commit 643edb5

Browse files
committed
add invalid_param error handling
1 parent 007d960 commit 643edb5

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

components/ironclad/actions/launch-workflow/launch-workflow.mjs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,17 @@ export default {
8888
return response;
8989
} catch (error) {
9090
const msg = JSON.parse(error.message);
91+
const { schema } = await ironclad.getWorkflowSchema({
92+
templateId,
93+
});
9194
if (msg.code === "MISSING_PARAM") {
92-
const { schema } = await this.ironclad.getWorkflowSchema({
93-
templateId: this.templateId,
94-
});
9595
const paramNames = (JSON.parse(msg.param)).map((p) => `\`${schema[p].displayName}\``);
9696
throw new ConfigurationError(`Please enter or update the following required parameters: ${paramNames.join(", ")}`);
9797
}
98+
if (msg.code === "INVALID_PARAM") {
99+
const paramName = schema[msg.metadata.keyPath].displayName;
100+
throw new ConfigurationError(`Invalid parameter: \`${paramName}\`. ${msg.message}`);
101+
}
98102
throw new ConfigurationError(msg.message);
99103
}
100104
},

components/ironclad/actions/update-workflow/update-workflow.mjs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,17 @@ export default {
9595
return response;
9696
} catch (error) {
9797
const msg = JSON.parse(error.message);
98+
const { schema } = await ironclad.getWorkflow({
99+
workflowId,
100+
});
98101
if (msg.code === "MISSING_PARAM") {
99-
const { schema } = await this.ironclad.getWorkflowSchema({
100-
templateId: this.templateId,
101-
});
102102
const paramNames = (JSON.parse(msg.param)).map((p) => `\`${schema[p].displayName}\``);
103103
throw new ConfigurationError(`Please enter or update the following required parameters: ${paramNames.join(", ")}`);
104104
}
105+
if (msg.code === "INVALID_PARAM") {
106+
const paramName = schema[msg.metadata.keyPath].displayName;
107+
throw new ConfigurationError(`Invalid parameter: \`${paramName}\`. ${msg.message}`);
108+
}
105109
throw new ConfigurationError(msg.message);
106110
}
107111
},

0 commit comments

Comments
 (0)