<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def error(self, message, data=None, code=None):
 """An error occurred in processing the request, i.e. an exception was thrown. :type data: A JSON-serializable object :param data: A generic container for any other information about the error, i.e. the conditions that caused the error, stack traces, etc. :type message: A JSON-serializable object :param message: A meaningful, end-user-readable (or at the least log-worthy) message, explaining what went wrong :type code: int :param code: A numeric code corresponding to the error, if applicable """

        result = {'status': 'error', 'message': message}
        if data:
            result['data'] = data
        if code:
            result['code'] = code
        self.write(result)
        self.finish()