Skip to content

Commit

Permalink
Merge pull request #550 from iamdefinitelyahuman/fix-vm-exception
Browse files Browse the repository at this point in the history
fix: KeyError when handling some RPC exceptions
  • Loading branch information
iamdefinitelyahuman authored May 24, 2020
2 parents c29c7d9 + 33b99b7 commit 8ad4c89
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion brownie/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ def __init__(self, exc: ValueError) -> None:
pass

if isinstance(exc, dict) and "message" in exc:
if "data" not in exc:
raise ValueError(exc["message"]) from None

self.message: str = exc["message"]
try:
txid, data = next((k, v) for k, v in exc["data"].items() if k.startswith("0x"))
Expand All @@ -95,7 +98,7 @@ def __init__(self, exc: ValueError) -> None:
if self.revert_msg is None and self.revert_type in ("revert", "invalid opcode"):
self.revert_msg = brownie.project.build._get_dev_revert(self.pc)
else:
self.message = str(exc)
raise ValueError(str(exc)) from None

def __str__(self) -> str:
if not hasattr(self, "revert_type"):
Expand Down

0 comments on commit 8ad4c89

Please sign in to comment.