Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: KeyError when handling some RPC exceptions #550

Merged
merged 1 commit into from
May 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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