Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

Commit

Permalink
Reduce subprocess verbosity on call, or invoke, error (#126)
Browse files Browse the repository at this point in the history
* Reduce `subprocess` verbosity on call, or involke, error

* improve logging

* improve logging

Co-authored-by: Martín Triay <[email protected]>
  • Loading branch information
ca11ab1e and martriay authored Aug 5, 2022
1 parent 1d1bc85 commit 32e72cf
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/nile/core/call_or_invoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,23 @@ def call_or_invoke(
command.append("--no_wallet")

try:
output = subprocess.check_output(command).strip().decode("utf-8")
return output

return subprocess.check_output(command).strip().decode("utf-8")
except subprocess.CalledProcessError:
p = subprocess.Popen(command, stderr=subprocess.PIPE)
_, error = p.communicate()
err_msg = error.decode()

if "max_fee must be bigger than 0" in error.decode():
if "max_fee must be bigger than 0" in err_msg:
logging.error(
"""
\n😰 Whoops, looks like max fee is missing. Try with:\n
--max_fee=`MAX_FEE`
"""
)
else:
raise
elif "transactions should go through the __execute__ entrypoint." in err_msg:
logging.error(
"\n\n😰 Whoops, looks like you're not using an account. Try with:\n"
"\nnile send [OPTIONS] SIGNER CONTRACT_NAME METHOD [PARAMS]"
)

return ""

0 comments on commit 32e72cf

Please sign in to comment.