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

added contextName option #15

Closed
wants to merge 3 commits into from
Closed

added contextName option #15

wants to merge 3 commits into from

Conversation

aponxi
Copy link

@aponxi aponxi commented Jun 19, 2018

I wanted to extend the use for not only plugins but any type of context. Since I'm using this in Gulp I wanted to have the error message be: Error in task run-tests rather than Error in plugin run-tests.

I hope I added the options to the right places.

✔️ The tests ran 100%.
✔️ Default value is plugin so it has backwards compatibility.

@demurgos
Copy link
Member

demurgos commented Jun 19, 2018

Hi,
Thanks for the PR. Before reviewing the code, I'd like to know if we want to add this feature at all.

Despite its name, plugin-error is intended for plugin errors, not general-purpose custom errors. 😉

Given your use-case (customizing the error message), I think that you could simply use your own custom error (class TaskError extends Error { ... }).

The problem with this PR is that the new property is only used to format the message. The other properties all provide information that can also be used to handle the errors programmatically. contextName is redundant with name. There's already an open issue (#9) to clarify the goal of this lib, but I feel that structured data attached to the error should be more important than the human-readable message.

Also, you can already provide arbitrary properties for the errors, I'd call them the context; then calling it .contextName is a bit confusing (again, I'd just use TaskError as the name of a custom error so I don't have a better idea for this prop).

I'm leaving this PR open if you or someone else wants to comment.

@yocontra yocontra requested a review from phated June 19, 2018 20:14
@phated
Copy link
Member

phated commented Jun 22, 2018

I think I agree with @demurgos here.

@demurgos
Copy link
Member

demurgos commented Jul 2, 2018

Closing this PR for the reasons explained above.

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