lambder 3.2.4 → 3.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Lambder.js +7 -3
- package/package.json +1 -1
package/dist/Lambder.js
CHANGED
|
@@ -431,22 +431,26 @@ export default class Lambder {
|
|
|
431
431
|
}
|
|
432
432
|
catch (err) {
|
|
433
433
|
const wrappedError = err instanceof Error ? err : new Error("Error: " + String(err));
|
|
434
|
+
// ctx may be null (createContext failed): derive the format from the raw event.
|
|
435
|
+
const eventFormat = ctx?._otherInternal.eventFormat ?? (isV2HttpEvent(event) ? "v2" : "v1");
|
|
434
436
|
try {
|
|
435
437
|
if (this.globalErrorHandler) {
|
|
436
438
|
const responseBuilder = this.getResponseBuilder(ctx ?? undefined);
|
|
437
439
|
const errorResponse = await this.globalErrorHandler(wrappedError, ctx, responseBuilder, ctx?._otherInternal.logToApiResponseAccumulator);
|
|
438
|
-
return await finalizeResponse(ctx, errorResponse, this.finalizeOptions,
|
|
440
|
+
return await finalizeResponse(ctx, errorResponse, this.finalizeOptions, eventFormat);
|
|
439
441
|
}
|
|
440
442
|
}
|
|
441
443
|
catch (handlerErr) {
|
|
442
444
|
if (handlerErr instanceof LambderResponse) {
|
|
443
445
|
try {
|
|
444
|
-
return await finalizeResponse(ctx, handlerErr, this.finalizeOptions,
|
|
446
|
+
return await finalizeResponse(ctx, handlerErr, this.finalizeOptions, eventFormat);
|
|
445
447
|
}
|
|
446
448
|
catch { /* fall through */ }
|
|
447
449
|
}
|
|
448
450
|
}
|
|
449
|
-
return
|
|
451
|
+
return eventFormat === "v2"
|
|
452
|
+
? { statusCode: 500, headers: {}, body: "Internal Server Error.", isBase64Encoded: false }
|
|
453
|
+
: { statusCode: 500, multiValueHeaders: {}, body: "Internal Server Error.", isBase64Encoded: false };
|
|
450
454
|
}
|
|
451
455
|
}
|
|
452
456
|
}
|