Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fallback should there be an error getting the functions error page template #4499

Merged
merged 2 commits into from
Apr 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
"/src/**/*.sh",
"/src/**/*.ps1",
"/src/functions-templates/**",
"/src/lib/functions/templates/**",
"!/src/**/node_modules/**",
"!/src/**/*.test.js"
],
Expand Down
9 changes: 7 additions & 2 deletions src/lib/functions/synchronous.js
Original file line number Diff line number Diff line change
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