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

Don't use throw new errors when original error was throw by us (we lose original error information) #5089

Closed
DonJayamanne opened this issue Mar 9, 2021 · 1 comment
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug

Comments

@DonJayamanne
Copy link
Contributor

We have 3 places where we rethrow the original error, but as a new error with additional information.
We had 2 places in the extension where this caused issues, basically:

  • We are throwing exception of type A
  • Then we handle this and rethrow this as a new error type B (but retain some of the original error information)
  • Further up, we check if the error is type A, and do something
  • However the error is no longer of type A, its a new error.

Again, this was fixed recently in a PR, but we still have at least 3 areas that still do this.
Solutions:

  • Ensure we do not throw new errors if we had thrown the original error

E.g. instead of
throw new WrappedError(localize.DataScience.jupyterNotebookFailure().format(err), err);
We change this to

if (err instanceof BaseError){
	throw err;
} else 
	throw new WrappedError(localize.DataScience.jupyterNotebookFailure().format(err), err);
}

This can be converted into a single liner as follows:

	throw WrappedError.from(err);

Where WrappedError.from can do the necessary checking.

@DonJayamanne DonJayamanne added the bug Issue identified by VS Code Team member as probable bug label Mar 9, 2021
@DonJayamanne DonJayamanne changed the title Don't use WrappedError for our own errors Don't use throw new errors when original error was throw by us (we lose original error information) Mar 9, 2021
@DavidKutu DavidKutu self-assigned this Mar 15, 2021
@IanMatthewHuff
Copy link
Member

Validated.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

3 participants