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

[CHIA-813] print EvalError in a slightly more user friendly way #428

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
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: 5 additions & 0 deletions wheel/python/clvm_rs/eval_error.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
from .ser import sexp_to_bytes

class EvalError(ValueError):
def __init__(self, message: str, sexp):
super().__init__(message)
self._sexp = sexp

def __str__(self) -> str:
return f"({self.args[0]}, {sexp_to_bytes(self._sexp).hex()})"
12 changes: 12 additions & 0 deletions wheel/python/tests/test_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,3 +493,15 @@ def test_tree_hash_no_caching(self):
self.assertEqual(p3p._cached_sha256_treehash.hex(), eh3)
self.assertEqual(p._cached_sha256_treehash.hex(), eh)
self.assertEqual(p2._cached_sha256_treehash.hex(), eh2)

def test_repr() -> None:
temp = Program.to([8, (1, "foo")])
assert f"{temp}" == "ff08ffff0183666f6f80"

Program.set_run_unsafe_max_cost(11000000000)

try:
temp.run([])
assert False
except EvalError as e:
assert f"{e}" == "(clvm raise, 83666f6f)"
Loading