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

Reduce subprocess verbosity on call, or invoke, error #126

Conversation

ca11ab1e
Copy link
Contributor

@ca11ab1e ca11ab1e commented Jun 2, 2022

Related to #117. Maybe reducing subprocess exception could be a first step until a better error reporting?

Before the patch:

Got BadRequest while trying to access https://alpha4.starknet.io/feeder_gateway/call_contract?blockNumber=null. Status code: 500; text: {"code": "StarknetErrorCode.UNINITIALIZED_CONTRACT", "message": "Contract with address 0x123 is not deployed."}.
Traceback (most recent call last):
  File "./venv/lib/python3.9/site-packages/services/external_api/base_client.py", line 120, in _send_request
    raise BadRequest(status_code=response.status, text=text)
services.external_api.base_client.BadRequest: HTTP error ocurred. Status: 500. Text: {"code": "StarknetErrorCode.UNINITIALIZED_CONTRACT", "message": "Contract with address 0x123 is not deployed."}
Error: BadRequest: HTTP error ocurred. Status: 500. Text: {"code": "StarknetErrorCode.UNINITIALIZED_CONTRACT", "message": "Contract with address 0x123 is not deployed."}
Traceback (most recent call last):
  File "./venv/bin/nile", line 8, in <module>
    sys.exit(cli())
  File "./venv/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "./venv/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "./venv/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "./venv/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "./venv/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "./venv/lib/python3.9/site-packages/nile/cli.py", line 132, in call
    out = call_or_invoke_command(contract_name, "call", method, params, network)
  File "./venv/lib/python3.9/site-packages/nile/core/call_or_invoke.py", line 40, in call_or_invoke
    return subprocess.check_output(command).strip().decode("utf-8")
  File "/usr/lib/python3.9/subprocess.py", line 424, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/lib/python3.9/subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['starknet', 'call', '--address', '0x123', '--abi', 'artifacts/abis/ERC721.json', '--function', 'get_animal_characteristics', '--inputs', '42', '0']' returned non-zero exit status 1.

With the patch:

Got BadRequest while trying to access https://alpha4.starknet.io/feeder_gateway/call_contract?blockNumber=null. Status code: 500; text: {"code": "StarknetErrorCode.UNINITIALIZED_CONTRACT", "message": "Contract with address 0x123 is not deployed."}.
Traceback (most recent call last):
  File "./venv/lib/python3.9/site-packages/services/external_api/base_client.py", line 120, in _send_request
    raise BadRequest(status_code=response.status, text=text)
services.external_api.base_client.BadRequest: HTTP error ocurred. Status: 500. Text: {"code": "StarknetErrorCode.UNINITIALIZED_CONTRACT", "message": "Contract with address 0x123 is not deployed."}
Error: BadRequest: HTTP error ocurred. Status: 500. Text: {"code": "StarknetErrorCode.UNINITIALIZED_CONTRACT", "message": "Contract with address 0x123 is not deployed."}

@ca11ab1e ca11ab1e changed the title Reduce subprocess verbosity on call, or involke, error Reduce subprocess verbosity on call, or invoke, error Jun 2, 2022
@andrew-fleming
Copy link
Contributor

Hey @ca11ab1e! Thanks for creating these PRs! Right now, we're focusing on getting v0.2.0 of Contracts for Cairo out, but we'll check these out as soon as we can :)

JulissaDantes
JulissaDantes previously approved these changes Jul 4, 2022
Copy link
Contributor

@JulissaDantes JulissaDantes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great addition, thank you!

martriay
martriay previously approved these changes Aug 3, 2022
Copy link
Contributor

@andrew-fleming andrew-fleming left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call including __execute__. This looks good to me!

@martriay martriay merged commit 32e72cf into OpenZeppelin:main Aug 5, 2022
@ca11ab1e ca11ab1e deleted the fix-117-reduce-subprocess-verbosity-on-error branch August 6, 2022 03:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants