implement error handler for get and post methods