Skip to content

Commit

Permalink
fix: wrap render template in try catch
Browse files Browse the repository at this point in the history
  • Loading branch information
jackiewmacharia committed Apr 1, 2022
1 parent a2bbaf0 commit c4f59ca
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/lib/functions/synchronous.js
Expand Up @@ -51,9 +51,14 @@ let errorTemplateFile

const renderErrorTemplate = async (errString) => {
const regexPattern = /<!--@ERROR-DETAILS-->/g
errorTemplateFile = errorTemplateFile || (await readFile(join(__dirname, './templates/function-error.html'), 'utf-8'))
const templatePath = './templates/function-error.html'

return errorTemplateFile.replace(regexPattern, errString)
try {
errorTemplateFile = errorTemplateFile || (await readFile(join(__dirname, templatePath), 'utf-8'))
return errorTemplateFile.replace(regexPattern, errString)
} catch {
return errString
}
}

const processRenderedResponse = async (err, request) => {
Expand Down

0 comments on commit c4f59ca

Please sign in to comment.