Skip to content

Rework Cast CLI errors #2572

Closed as not planned
Closed as not planned
@integraledelebesgue

Description

@integraledelebesgue

Component the issue is related to

Cast

Issue

Errors in Cast are propagated in a few inconsistent ways:

  1. unwrap or expect - not only for strictly critical errors like runtime instantiation, but also for things like failed compilation (see here)

  2. A nice error descriptions generated by print_command_result, e.g.

command: invoke
error: An error occurred in the called contract[..]Requested contract address 0x1 is not deployed[..]

Those appear only for errors thrown by main command handlers (e.g. starknet_commands::declare::declare) and no other errors possible to occur during command execution.

  1. anyhow::Error returned by main::run_async_command - errors from helper functions like get_block_id (here) called before the main command handler are just propagated upwards and get printed in the console with no command info present in 2.

We could introduce consistent error handling accross all cast functionalities by substituting expects with bails and moving print_command_result calls outside the giant match in run_async_command so all the errors are presented to user in the same style.
Perhaps some extension/rework of print_command_result is necessary.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions