MCPcopy Create free account
hub / github.com/CodeGenieApp/serverless-express / respondToEventSourceWithError

Function respondToEventSourceWithError

src/transport.js:52–85  ·  view source on GitHub ↗
({
  error,
  resolver,
  log,
  respondWithErrors,
  eventSourceName,
  eventSource,
  event
})

Source from the content-addressed store, hash-verified

50}
51
52function respondToEventSourceWithError ({
53 error,
54 resolver,
55 log,
56 respondWithErrors,
57 eventSourceName,
58 eventSource,
59 event
60}) {
61 log.error('SERVERLESS_EXPRESS:RESPOND_TO_EVENT_SOURCE_WITH_ERROR', error)
62
63 if (
64 eventSourceName !== 'AWS_ALB' &&
65 eventSourceName !== 'AWS_LAMBDA_EDGE' &&
66 eventSourceName !== 'AWS_API_GATEWAY_V1' &&
67 eventSourceName !== 'AWS_API_GATEWAY_V2' &&
68 eventSourceName !== 'AZURE_HTTP_FUNCTION_V3' &&
69 eventSourceName !== 'AZURE_HTTP_FUNCTION_V4'
70 ) {
71 resolver.fail({ error })
72 return
73 }
74
75 const body = respondWithErrors ? error.stack : ''
76 const errorResponse = eventSource.getResponse({
77 event,
78 statusCode: 500,
79 body,
80 headers: {},
81 isBase64Encoded: false
82 })
83
84 resolver.succeed({ response: errorResponse })
85}
86
87async function getRequestResponse ({
88 method,

Callers 1

handleErrorFunction · 0.85

Calls 2

failMethod · 0.80
succeedMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…