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

Handle Exceptions in CLI scope #319

@ericnordelo

Description

@ericnordelo

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions