@classmethod
def handle_response(cls, handler, payload):
    """JSON v1 response handler.  Both 'error' and 'result'
        should exist with exactly one being None.
        Unfortunately many 1.0 clients behave like 2.0, and just send
        one or the other.
        """
    error = payload.get('error')
    if error is None:
        handler(payload.get('result'), None)
    else:
        handler(None, cls.canonical_error(error))
