Python: How to get error messages from SDK?

Hi all,

I am trying to make a transaction using the Python SDK. It is a simple script run at the command line to make regular payments. But I am struggling to build the transaction.

This is what I have in the try…except block:

algod_client = algod.AlgodClient(algod_token='', 
params = algod_client.suggested_params()

    unsigned_txn = transaction.AssetTransferTxn(
        note=b"Test run.",
except Exception as e:
    print("ERROR:", vars(e))

This block of code simply prints out:


How do I get better error information? What am I missing?

Thanks in advance.

You will get better error information by printing full exception object:

print("ERROR:", e)

Thanks for the response.

This is pretty much where I started. It just prints:


and nothing else. Which is why I tried to see if vars() would show me anything else.


I noticed that this is the case when amount is negative. It is a bug in the SDK, error.WrongAmountType does not initialize parent Exception class properly.

Can you perhaps validate the amount separately at the moment?

PS: print(type(e)) helps to deduce the error type even if message is empty.

1 Like

Interesting. I have just tried that.

You nailed it. The amount was type string. My bad. I forgot to convert it.

Will have to check the Github and see if this bug has been reported. :slight_smile:

Thanks for all the help. Very much appreciated.