This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import middy from '@middy/core'; | |
// Business logic | |
const businessLogic = async (event) => { | |
... | |
return myResponse; | |
}; | |
// Configuration | |
export const myHandler = middy(businessLogic).onError(handleError); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CustomError extends Error { | |
constructor(statusCode, { key, message }) { | |
super(message); | |
this.statusCode = statusCode; | |
this.key = key; | |
} | |
} | |
export class BadRequestError extends CustomError { | |
constructor({ |
NewerOlder