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

Handle Exceptions in CLI scope #319

Open
ericnordelo opened this issue Nov 30, 2022 · 0 comments
Open

Handle Exceptions in CLI scope #319

ericnordelo opened this issue Nov 30, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@ericnordelo
Copy link
Member

ericnordelo commented Nov 30, 2022

Currently, we are handling some exceptions in code shared between CLI and NRE as if they were used only in CLI (logging and returning empty output). For example:

try:
output = await execute_call(
type,
network,
inputs=params,
signature=signature,
max_fee=max_fee,
query_flag=query_flag,
address=hex_address(address),
abi=abi,
method=method,
)
except BaseException as err:
if "max_fee must be bigger than 0." in str(err):
logging.error(
"""
\n😰 Whoops, looks like max fee is missing. Try with:\n
--max_fee=`MAX_FEE`
"""
)
return
else:
logging.error(err)
return

When account.send is called from scripts, if an exception occurs, the call will return an empty response, and the exception won't be raised. This can make the user confused about what is happening, as he probably won't be checking the logging output in a script.

I think we should, as a general rule, avoid try-catching and logging outside the CLI.

Also, I think it would be helpful to implement a class handling exceptions for the CLI as a centralized entity instead of different try/catches in multiple places.

This is helpful for UX and code maintainability and extensibility.

EDIT: The code preview is not showing all the lines I wanted, but if you go to that section, and check the catch block, you will see the empty return.

EDIT 2: I think this could relate to handling watch_mode in NRE (see this issue).

@ericnordelo ericnordelo added the enhancement New feature or request label Nov 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
No open projects
Status: 📋 Backlog
Development

No branches or pull requests

1 participant