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

web3js deviates from the Error handling standard #6388

Closed
moshmage opened this issue Aug 28, 2023 · 3 comments · Fixed by #6631
Closed

web3js deviates from the Error handling standard #6388

moshmage opened this issue Aug 28, 2023 · 3 comments · Fixed by #6631
Assignees
Labels
4.x 4.0 related 5.x 5.0 related issues Enhancement Includes improvements or optimizations

Comments

@moshmage
Copy link
Contributor

moshmage commented Aug 28, 2023

on the creation of a ContractExecutionError that extends a Web3ContractError (that ultimately extends an Error) the code starts the super class (eventually starting the Error) with a pre-defined message ("Error happened while trying to execute a function inside a smart contract") and appends the original error in a innerError prop.

This causes a deviance from Error handling standards, as a developer I'd like to know the actual stack and error message, and cause, that came along.

I propose to use the cause standard and call super('message', {cause: rpcError})

Expected behavior

  • Errors to use {cause: error}

Actual behavior

  • Errors use innerError

Steps to reproduce the behavior

Check this line, https://github.com/web3/web3.js/blob/4.x/packages/web3-errors/src/errors/contract_errors.ts#L222

Environment

  • web3js 4.1.0
@moshmage moshmage changed the title web3js overrides transaction error object, escaping the standard web3js deviates from the Error handling standard Aug 28, 2023
@jdevcs
Copy link
Contributor

jdevcs commented Aug 28, 2023

Thanks for details and proposing improvement, We will discuss this in team.

@jdevcs jdevcs added 4.x 4.0 related Enhancement Includes improvements or optimizations labels Aug 28, 2023
@mconnelly8 mconnelly8 added the 5.x 5.0 related issues label Oct 17, 2023
@calmacfadden
Copy link

This issue impacts the ethereum remix ide.
ethereum/remix-project#4241

@mconnelly8
Copy link

Need to investigate

@Muhammad-Altabba Muhammad-Altabba self-assigned this Nov 28, 2023
@Muhammad-Altabba Muhammad-Altabba linked a pull request Nov 29, 2023 that will close this issue
17 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.x 4.0 related 5.x 5.0 related issues Enhancement Includes improvements or optimizations
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants