omgnetwork / plasma-mvp

OmiseGO's research implementation of Minimal Viable Plasma
MIT License
561 stars 158 forks source link

Improve ChildChainService error handling #99

Closed smartcontracts closed 6 years ago

smartcontracts commented 6 years ago

Errors are not handled in ChildChainService. An invalid request will simply result in the following KeyError:

KeyError: 'result'

This error occurs because ChildChainService expects each response to have a 'result' field:

    def send_request(self, method, args):
        payload = {
            "method": method,
            "params": args,
            "jsonrpc": "2.0",
            "id": 0,
        }
        response = requests.post(self.url, json=payload).json()
        return response["result"]

We should handle this gracefully, perhaps by passing the error back through the server and into the child chain service.