Skip to content

Instantly share code, notes, and snippets.

class CustomError extends Error {
constructor(statusCode, { key, message }) {
super(message);
this.statusCode = statusCode;
this.key = key;
}
}
export class BadRequestError extends CustomError {
constructor({
const createProxyHttpResponse = ({ statusCode, key, message }) => ({
statusCode,
body: JSON.stringify({ key, message }),
headers: { 'Content-Type': 'application/json' },
});
const formatErrorForApiGateway = async ({ error, callback }) =>
callback(
null,
createProxyHttpResponse(