diff --git a/backend/internal/certificate.js b/backend/internal/certificate.js index 19e0592..3725c1c 100644 --- a/backend/internal/certificate.js +++ b/backend/internal/certificate.js @@ -216,6 +216,13 @@ const internalCertificate = { return saved_row; }); }); + }).catch(async (error) => { + // Delete the certificate from the database if it was not created successfully + await certificateModel + .query() + .deleteById(certificate.id); + + throw error; }); } else { return certificate;