Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
qalisander opened this issue Jul 24, 2024 · 0 comments · May be fixed by #136
Open

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

qalisander opened this issue Jul 24, 2024 · 0 comments · May be fixed by #136

Comments

@qalisander
Copy link

qalisander commented Jul 24, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant