fix error responses by adding error handler