Skip to content

Commit 64f971d

Browse files
keanu-aserhalp
andauthored
refactor: use renderFunctionErrorPage from @netlify/dev-utils (#7451)
* Replaced usages of renderErrorTemplate with renderFunctionErrorPage * refactor: remove function-error.html template --------- Co-authored-by: Philippe Serhal <[email protected]>
1 parent 91b6c55 commit 64f971d

File tree

4 files changed

+4
-331
lines changed

4 files changed

+4
-331
lines changed

src/lib/functions/synchronous.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { Buffer } from 'buffer'
22
import { inspect } from 'util'
33

4+
import { renderFunctionErrorPage } from '@netlify/dev-utils'
45
import express from 'express'
56
import { isReadableStream as baseIsReadableStream } from 'is-stream'
67
import type { LambdaEvent } from 'lambda-local'
78

89
import { chalk, logPadded, NETLIFYDEVERR } from '../../utils/command-helpers.js'
9-
import renderErrorTemplate from '../render-error-template.js'
1010

1111
import { warnIfAwsSdkError } from './utils.js'
1212
import type { InvocationError } from './netlify-function.js'
@@ -161,7 +161,7 @@ const handleErr = async (
161161

162162
if (acceptsHtml) {
163163
response.setHeader('Content-Type', 'text/html')
164-
response.end(await renderErrorTemplate(errorString, '../../src/lib/templates/function-error.html', 'function'))
164+
response.end(await renderFunctionErrorPage(errorString, 'function'))
165165
} else {
166166
response.end(errorString)
167167
}

src/lib/render-error-template.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/lib/templates/function-error.html

Lines changed: 0 additions & 303 deletions
This file was deleted.

src/utils/proxy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import url from 'url'
1313
import util from 'util'
1414
import zlib from 'zlib'
1515

16+
import { renderFunctionErrorPage } from '@netlify/dev-utils'
1617
import contentType from 'content-type'
1718
import cookie from 'cookie'
1819
import { getProperty } from 'dot-prop'
@@ -37,7 +38,6 @@ import { fileExistsAsync, isFileAsync } from '../lib/fs.js'
3738
import { getFormHandler } from '../lib/functions/form-submissions-handler.js'
3839
import { DEFAULT_FUNCTION_URL_EXPRESSION } from '../lib/functions/registry.js'
3940
import { initializeProxy as initializeImageProxy, isImageRequest } from '../lib/images/proxy.js'
40-
import renderErrorTemplate from '../lib/render-error-template.js'
4141

4242
import { NETLIFYDEVLOG, NETLIFYDEVWARN, type NormalizedCachedConfigConfig, chalk, log } from './command-helpers.js'
4343
import createStreamPromise from './create-stream-promise.js'
@@ -731,7 +731,7 @@ const initializeProxy = async function ({
731731
const decompressedBody = await decompressResponseBody(responseBody, proxyRes.headers['content-encoding'])
732732
const formattedBody = formatEdgeFunctionError(decompressedBody, acceptsHtml)
733733
const errorResponse = acceptsHtml
734-
? await renderErrorTemplate(formattedBody, '../../src/lib/templates/function-error.html', 'edge function')
734+
? await renderFunctionErrorPage(formattedBody, 'edge function')
735735
: formattedBody
736736
const contentLength = Buffer.from(errorResponse, 'utf8').byteLength
737737

0 commit comments

Comments
 (0)