Skip to content

feature: add possibility to reuse error for the other contract #135

@qalisander

Description

@qalisander

It is convenient to declare errors in different modules. And reuse the error from the other module inside an enum.

Currently the following pattern for error structure doesn't work for SolidityError proc macro:

#[derive(SolidityError, Debug)]
pub enum Error {
    Erc721(Erc721Error),
    Checkpoints(CheckpointError),
    ForbiddenBatchMint(ERC721ForbiddenBatchMint),
    ExceededMaxBatchMint(ERC721ExceededMaxBatchMint),
    ForbiddenMint(ERC721ForbiddenMint),
    ForbiddenBatchBurn(ERC721ForbiddenBatchBurn),
}

#[derive(SolidityError, Debug)]
pub enum Erc721Error {
    InsufficientBalance(ERC721InsufficientBalance),
    InvalidSender(ERC721InvalidSender),
    InvalidReceiver(ERC721InvalidReceiver),
    InsufficientAllowance(ERC721InsufficientAllowance),
    InvalidSpender(ERC721InvalidSpender),
}

#[derive(SolidityError, Debug)]
pub enum CheckpointError {
    CheckpointUnorderedInsertion(CheckpointUnorderedInsertion),
}

Compilation fails with: "the trait bound Error: stylus_sdk::call::MethodError is not satisfied".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions