iroha-python icon indicating copy to clipboard operation
iroha-python copied to clipboard

Better Exceptions.

Open appetrosyan opened this issue 3 years ago • 2 comments

Because iroha-python is a wrapper around rust code, the full trace-back for an exception is truncated to the Python code in which it was called. So all exceptions should contain the maximum amount of information.

For example

Traceback (most recent call last):
   File "/mnt/Archive/Git/iroha-python/example/./test.py", line 18, in <module>
hash = cl.submit_isi(register)
   File "/home/app/.local/lib/python3.9/site-packages/iroha2/__init__.py", line 39, in submit_isi
return self.submit_tx([_Instruction(isi)])
   File "/home/app/.local/lib/python3.9/site-packages/iroha2/__init__.py", line 36, in submit_tx
return self.cl.submit_all_with_metadata(tx, {})
   Exception: Failed to send transaction with hash HashOf(7f95850f295eb71cc94c40923a93f1e26d34dd401f216698a5fc4d2292344d26, PhantomData)

is insufficiently informative.

appetrosyan avatar Nov 16 '21 10:11 appetrosyan

I'm moving the information from #137 here, as it is a duplicate.

Today, sgull reported an error while trying to run the most basic documentation example while using a default config from the docs.

import json
from iroha2 import Client

cfg = json.loads(open("config.json").read())
cl = Client(cfg)

This is the error log, which, honestly, doesn't tell a lot to respond about:

Exception                                 Traceback (most recent call last)
Cell In[55], line 6
      4 cfg = json.loads(open("config.json").read())
      5 # cfg
----> 6 cl = Client(cfg)

File ~/.local/lib/python3.10/site-packages/iroha2/__init__.py:13, in Client.__init__(self, cfg, headers)
     11 def __init__(self, cfg, headers=None):
     12     if headers is None:
---> 13         self.cl = _Client(cfg)
     14     else:
     15         self.cl = _Client.with_headers(cfg, headers)

This error also repeats when he tries to run a test.py file.

6r1d avatar Mar 03 '23 07:03 6r1d

update: running the code with a modified config ( removing "ACCOUNT_ID": "alice@wonderland", ) seems to go through without any errors

h4rit avatar Mar 03 '23 09:03 h4rit