File tree Expand file tree Collapse file tree 2 files changed +6
-8
lines changed Expand file tree Collapse file tree 2 files changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ import type { LambdaEvent } from 'lambda-local'
88import { chalk , logPadded , NETLIFYDEVERR } from '../../utils/command-helpers.js'
99import renderErrorTemplate from '../render-error-template.js'
1010
11- import { detectAwsSdkError } from './utils.js'
11+ import { warnIfAwsSdkError } from './utils.js'
1212import type { InvocationError } from './netlify-function.js'
1313
1414// Annoyingly, `isReadableStream` refines to the `Readable` interface rather than the
@@ -152,8 +152,7 @@ const handleErr = async (
152152 request : express . Request ,
153153 response : express . Response ,
154154) => {
155- // @ts -expect-error -- XXX(serhalp): Expects `error` but passes `err`, so it has never worked. Fixed in stacked PR.
156- detectAwsSdkError ( { err } )
155+ warnIfAwsSdkError ( { error : err } )
157156
158157 const acceptsHtml = request . headers . accept ?. includes ( 'text/html' ) ?? false
159158 const errorString = typeof err === 'string' ? err : formatLambdaLocalError ( err , acceptsHtml )
Original file line number Diff line number Diff line change @@ -3,8 +3,7 @@ import { MISSING_AWS_SDK_WARNING } from '../log.js'
33
44import type { InvocationError } from './netlify-function.js'
55
6- // TODO(serhalp): Rename? This doesn't "detect", it maybe logs a warning.
7- export const detectAwsSdkError = ( { error } : { error : Error | InvocationError | string } ) : void => {
6+ export const warnIfAwsSdkError = ( { error } : { error : Error | InvocationError | string } ) : void => {
87 const isAwsSdkError =
98 typeof error === 'object' &&
109 'errorMessage' in error &&
@@ -16,10 +15,10 @@ export const detectAwsSdkError = ({ error }: { error: Error | InvocationError |
1615 }
1716}
1817
19- // XXX(serhalp): This appears to be a bug? In the background and scheduled function code paths this can receive plain
20- // errors, but this is assuming normalized `InvocationError`s only.
2118export const formatLambdaError = ( err : Error | InvocationError ) : string =>
22- chalk . red ( `${ 'errorType' in err ? err . errorType : '' } : ${ 'errorMessage' in err ? err . errorMessage : '' } ` )
19+ chalk . red (
20+ `${ 'errorType' in err ? err . errorType : 'Error' } : ${ 'errorMessage' in err ? err . errorMessage : err . message } ` ,
21+ )
2322
2423// should be equivalent to https://github.com/netlify/proxy/blob/main/pkg/functions/request.go#L105
2524const exceptionsList = new Set ( [
You can’t perform that action at this time.
0 commit comments