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

Migrate all errors to web3-common as error constructors #4359

Closed
nazarhussain opened this issue Sep 23, 2021 · 0 comments · Fixed by #4377
Closed

Migrate all errors to web3-common as error constructors #4359

nazarhussain opened this issue Sep 23, 2021 · 0 comments · Fixed by #4377
Assignees
Labels
4.x 4.0 related

Comments

@nazarhussain
Copy link
Contributor

Description

Need to migrate all errors from 1.x branch to web3-common package as error constructors.

https://github.com/ChainSafe/web3.js/blob/40974e9fe9a8f9075fcbb4c002430c6480d83031/packages/web3-core-helpers/src/errors.js#L27-L136

These error constructors should follow following pattern and extend base class Web3Error.

class Web3Error extends Error {
	public name: string;
	public code = 'ERR_WEB3';
	public constructor(...args: unknown[]) {
		super(...unknown);
		this.name = this.constructor.name;
		Error.captureStackTrace(this, Web3Error);
	}
}

class  InvalidConnectionError extends Web3Error {
   constructor(host, event) {
      super(`CONNECTION ERROR: Couldn\'t connect to node ${host}.');  
      this.code = 'ERR_CONNECTION_ERR';
   } 
}

Acceptance Criteria

  • All errors should be migrated
  • All errors should have minimum unit tests

Additional Information

  • Use string interpolation instead of concatenation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.x 4.0 related
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant