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)
def return_error ( self , status , payload = None ) : 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 )
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()