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

Monorepo: error handling tracking issue #3712

Open
jochem-brouwer opened this issue Sep 30, 2024 · 0 comments
Open

Monorepo: error handling tracking issue #3712

jochem-brouwer opened this issue Sep 30, 2024 · 0 comments

Comments

@jochem-brouwer
Copy link
Member

This issue summarizes issues/PRs raised in the past to improve monorepo error handling.

An old issue related to this is: #487

The core of the issue raised here is that errors themselves (new Error()) can only be distinguished by their error string. So, to compare errors (if a certain error is expected), can only be done by string. Therefore, changing the error string is a breaking issue. The idea here is to make a new class which extends Error, and add extra fields which can help for debug situations.

In EVM we already have EvmError:

export class EvmError {
  error: ERROR
  errorType: string

  constructor(error: ERROR) {
    this.error = error
    this.errorType = 'EvmError'
  }
}

The nice properties of this is that, if an error gets thrown, one can now:

catch(e: unknown) {
  if (e instanceof EvmError) {
    // error was thrown by evm, handle here
  } else {
    // another error (non-EVM) was thrown
  }
}

This old issue raises this idea as well: #1440 along with a discussion: #1439

There is also an old PR open which implements these ideas in a general was (in the util package) and errors in the block package: #1910

The general goal of this issue is:

  • Ensure that monorepo-wide we align the way of error handling
  • Errors are easily distinguishable by some kind of error code

This can be done per-package once we have created a way to base-handle these errors. (I will open a PR for this which also handles the errors that way in EVM)

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

No branches or pull requests

1 participant