Sometimes Solana returns 'err' as a string instead of an array of strings.

This commit is contained in:
Geoff Taylor 2021-08-09 21:07:21 +01:00
parent 3880cdb6ae
commit 94c6fa149e
1 changed files with 3 additions and 1 deletions

View File

@ -281,7 +281,9 @@ class CompatibleClient:
error_code: int = response["error"]["code"] if "code" in response["error"] else -1
error_data: typing.Dict = response["error"]["data"] if "data" in response["error"] else {}
error_accounts = error_data["accounts"] if "accounts" in error_data else "No accounts"
error_err = error_data["err"] if "err" in error_data else "No err"
error_err = error_data["err"] if "err" in error_data else "No error text returned"
if isinstance(error_err, str):
error_err = [error_err]
error_logs = error_data["logs"] if "logs" in error_data else "No logs"
raise TransactionException(exception_message, error_code, self.name,
error_accounts, error_err, error_logs)