diff --git a/wheel/python/clvm_rs/eval_error.py b/wheel/python/clvm_rs/eval_error.py index 5174e324..23d3d703 100644 --- a/wheel/python/clvm_rs/eval_error.py +++ b/wheel/python/clvm_rs/eval_error.py @@ -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()})" diff --git a/wheel/python/tests/test_program.py b/wheel/python/tests/test_program.py index 52510a86..32f43448 100644 --- a/wheel/python/tests/test_program.py +++ b/wheel/python/tests/test_program.py @@ -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)"