Skip to content

Add HarmonyLinkingError class - #6932

Merged
sokra merged 3 commits into
webpack:masterfrom
mohsen1:hideStack
Apr 4, 2018
Merged

sokra merged 3 commits into
webpack:masterfrom
mohsen1:hideStack

Conversation

@mohsen1

@mohsen1 mohsen1 commented Apr 2, 2018

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?
Refactoring

Did you add tests for your changes?
No

If relevant, link to documentation update:
N/A

Summary
Instead of adding a property to Error, introduce a new error constructor that has this property set to true. This will help TypeScript migration (#6862) as well.

Does this PR introduce a breaking change?
Hopefully not!

`Can't reexport ${exportName} from non EcmaScript module (only default export is available)`
);
err.hideStack = true;
return [err];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline the new HiddenStackError call into the array construction.

const err = new Error(errorMessage);
err.hideStack = true;
const err = new HiddenStackError(errorMessage);
return [err];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

`Can't import ${exportName} from non EcmaScript module (only default export is available)`
);
err.hideStack = true;
return [err];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

const err = new Error(errorMessage);
err.hideStack = true;
const err = new HiddenStackError(errorMessage);
return [err];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

Comment thread lib/HiddenStackError.js Outdated
*/
"use strict";

module.exports = class HiddenStackError extends Error {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inherit from WebpackError like the other Error classes.

Maybe you can make the class more meaningful by naming it like HarmonyLinkingError?

@webpack-bot

Copy link
Copy Markdown
Contributor

@mohsen1 Thanks for your update.

I labeled the Pull Request so reviewers will review it again.

@sokra Please review the new changes.

@@ -3,4 +3,4 @@ module.exports = function() {
err.stack = "Stack";
err.hideStack = true;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how these tests work. Can I import HarmonyLinkingError here too?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could, but this test is already fine. Loaders won't do use HarmonyLinkingError since they probably have own error classes or just add a property.

@mohsen1 mohsen1 changed the title Add HideStackError class for errors that have hideStack = true Add HarmonyLinkingError class Apr 4, 2018
@webpack-bot

Copy link
Copy Markdown
Contributor

Thank you for your pull request! The most important CI builds succeeded, we’ll review the pull request soon.

@@ -3,4 +3,4 @@ module.exports = function() {
err.stack = "Stack";
err.hideStack = true;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could, but this test is already fine. Loaders won't do use HarmonyLinkingError since they probably have own error classes or just add a property.

@sokra
sokra merged commit e65751a into webpack:master Apr 4, 2018
@sokra

sokra commented Apr 4, 2018

Copy link
Copy Markdown
Member

Thanks

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 this pull request may close these issues.

3 participants