How to add error handling for all functions?

I am using it with go & aws lambda. I want to add rollbar to handle errors.

Is there any sample code or any ways for handling an error with generic code?

I would create a custom middleware… see below:

You need to hook up to the onError hook… and there you have access to the request and the error. I would just post the error to rollbar…

1 Like

I was going to suggest Middy too, its a great addition. But @Hareramrai mentions they’re using Go so i don’t believe it will work. You’ll have to search for “lambda middleware” and see whats out there. I just saw one called Vesper (https://github.com/mefellows/vesper) but I don’t have any experience with it personally.