diff --git a/src/lib/functions/synchronous.js b/src/lib/functions/synchronous.js index 530a00dd6fd..2af21d4d5af 100644 --- a/src/lib/functions/synchronous.js +++ b/src/lib/functions/synchronous.js @@ -50,7 +50,9 @@ const processRenderedResponse = async (err, request) => { const acceptsHtml = request.headers && request.headers.accept && request.headers.accept.includes('text/html') const errorString = typeof err === 'string' ? err : formatLambdaLocalError(err, acceptsHtml) - return acceptsHtml ? await renderErrorTemplate(errorString, './templates/function-error.html') : errorString + return acceptsHtml + ? await renderErrorTemplate(errorString, './templates/function-error.html', 'function') + : errorString } const handleErr = async (err, request, response) => { diff --git a/src/lib/render-error-remplate.js b/src/lib/render-error-remplate.js index 09c96a0a7d8..766f153b666 100644 --- a/src/lib/render-error-remplate.js +++ b/src/lib/render-error-remplate.js @@ -3,12 +3,12 @@ const { join } = require('path') let errorTemplateFile -const renderErrorTemplate = async (errString, templatePath) => { - const regexPattern = //g - +const renderErrorTemplate = async (errString, templatePath, functionType) => { + const errorDetailsRegex = //g + const functionTypeRegex = //g try { errorTemplateFile = errorTemplateFile || (await readFile(join(__dirname, templatePath), 'utf-8')) - return errorTemplateFile.replace(regexPattern, errString) + return errorTemplateFile.replace(errorDetailsRegex, errString).replace(functionTypeRegex, functionType) } catch { return errString } diff --git a/src/lib/templates/edge-function-error.html b/src/lib/templates/edge-function-error.html deleted file mode 100644 index 6187cd6846c..00000000000 --- a/src/lib/templates/edge-function-error.html +++ /dev/null @@ -1,289 +0,0 @@ - - - - Invocation Failed - - - - - - - -
-
-
-

- - This edge function has crashed -

-

An unhandled error in the edge function code triggered the following message:

- -
- -
- - -
- - -
- - diff --git a/src/lib/templates/function-error.html b/src/lib/templates/function-error.html index 81e8c0bfb78..b32ee4231b1 100644 --- a/src/lib/templates/function-error.html +++ b/src/lib/templates/function-error.html @@ -197,7 +197,9 @@

fill="#900B31" /> - This function has crashed + This + + has crashed

An unhandled error in the function code triggered the following message:

Stack trace

- - - - -
-

Next steps

-
- - diff --git a/src/utils/proxy.js b/src/utils/proxy.js index bdebb7a92c0..36487b3d654 100644 --- a/src/utils/proxy.js +++ b/src/utils/proxy.js @@ -413,7 +413,7 @@ const initializeProxy = async function ({ configPath, distDir, port, projectDir const decompressedBody = await decompress(responseBody) const formattedBody = formatEdgeFunctionError(decompressedBody, acceptsHtml) const errorResponse = acceptsHtml - ? await renderErrorTemplate(formattedBody, './templates/edge-function-error.html') + ? await renderErrorTemplate(formattedBody, './templates/function-error.html', 'edge function') : formattedBody const contentLength = Buffer.from(errorResponse, 'utf8').byteLength