<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def return_error(self, status, payload=None):
 """Error handler called by request handlers when an error occurs and the request should be aborted. Usage:: def handle_post_request(self, *args, **kwargs):
 self.request_handler = self.get_request_handler() try: self.request_handler.process(self.get_data()) except SomeException as e: self.return_error(400, payload=self.request_handler.errors) return self.return_create_response() """

        resp = None
        if payload is not None:
            payload = json.dumps(payload)
            resp = self.make_response(payload, status=status)

        if status in [405]:
            abort(status)
        else:
            abort(status, response=resp)