diff --git a/CHANGELOG.md b/CHANGELOG.md index 67fcbc168..3d73ec5e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Protocol: gossipd now deliberately delays spamming with `channel_update`. - Config: `--conf` option to set config file. - JSON API: Added description to invoices and payments (#1740). +- pylightning: RpcError now has `method` and `payload` fields. ### Changed diff --git a/contrib/pylightning/lightning/lightning.py b/contrib/pylightning/lightning/lightning.py index 1891c1d28..08a3c06e6 100644 --- a/contrib/pylightning/lightning/lightning.py +++ b/contrib/pylightning/lightning/lightning.py @@ -4,8 +4,12 @@ import socket class RpcError(ValueError): - def __init__(self, description, error=None): - super(ValueError, self).__init__(description) + def __init__(self, method, payload, error): + super(ValueError, self).__init__("RPC call failed: method: {}, payload: {}, error: {}" + .format(method, payload, error)) + + self.method = method + self.payload = payload self.error = error @@ -73,12 +77,7 @@ class UnixDomainSocketRpc(object): self.logger.debug("Received response for %s call: %r", method, resp) if "error" in resp: - raise RpcError( - "RPC call failed: method: {}, payload: {}, error: {}".format( - method, - payload, - resp['error'] - ), resp['error']) + raise RpcError(method, payload, resp['error']) elif "result" not in resp: raise ValueError("Malformed response, \"result\" missing.") return resp["result"]