Improvements

This commit is contained in:
ricardo
2020-05-30 19:03:58 -04:00
parent 91c40367e1
commit 4e9490a88d
11 changed files with 62 additions and 45 deletions

View File

@@ -241,13 +241,26 @@ export class ActiveWorkflowRunner {
}
} catch (error) {
// The workflow was saved with two webhooks with the
// same path/method so delete all webhooks saved
let errorMessage = '';
await Db.collections.Webhook?.delete({ workflowId: workflow.id });
// then show error to the user
throw new Error(error.message || error.detail);
// if it's a workflow from the the insert
// TODO check if there is standard error code for deplicate key violation that works
// with all databases
if (error.name === 'QueryFailedError') {
errorMessage = `The webhook path [${webhook.webhookPath}] and method [${webhook.method}] already exist.`;
} else if (error.detail) {
// it's a error runnig the webhook methods (checkExists, create)
errorMessage = error.detail;
} else {
errorMessage = error;
}
throw new Error(errorMessage);
}
}
// Save static data!