-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: add error page to edge functions for local dev (#5070)
* feat: getting error page to edge functions * feat: set content length to have correct headers * feat: move render-error-template to own file * feat: render edge function error in its own template * feat: parse error in proxy file * feat: change parsing in formatEdgeFunctionError, remove default fallback in renderer * feat: remove check on 500 status code * feat: remove redundant function error template and clean old one
- Loading branch information
1 parent
91506bb
commit b9e0917
Showing
4 changed files
with
62 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const { readFile } = require('fs').promises | ||
const { join } = require('path') | ||
|
||
let errorTemplateFile | ||
|
||
const renderErrorTemplate = async (errString, templatePath, functionType) => { | ||
const errorDetailsRegex = /<!--@ERROR-DETAILS-->/g | ||
const functionTypeRegex = /<!--@FUNCTION-TYPE-->/g | ||
try { | ||
errorTemplateFile = errorTemplateFile || (await readFile(join(__dirname, templatePath), 'utf-8')) | ||
return errorTemplateFile.replace(errorDetailsRegex, errString).replace(functionTypeRegex, functionType) | ||
} catch { | ||
return errString | ||
} | ||
} | ||
|
||
module.exports = renderErrorTemplate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b9e0917
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📊 Benchmark results
Package size: 223 MB