-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
Errors thrown by this plugin are not instances of Error #89
Comments
@silvenon Could you give a link to the repository where this can be reproduced? Now I can’t give a definite answer, I need to see what happens. |
+cb(new Error(PLUGIN_NAME, err.message)) I think this solution is more correct, it may be worth updating this package because It has not been updated for a long time. Why do you use |
Technically it's a workaround, so first I wanted to see if there was a way to solve the issue at the root ("the right way"), but for my purposes it's fine either way, so I'll submit a PR to gulp-posthtml. I use gulp to build static sites, gulp v4 kinda changed the game for me. I have a bunch of HTML pages which I process with posthtml (sometimes first markdown, then posthtml) and output. Static site generators feel either too restrictive or too cumbersome to me. What tools do you use? Closing this because I'l solve this in gulp-posthtml. |
- rename Error to PluginError to not shadow actual Error - consistenly use PluginError - handle posthtml-expressions errors by not passing the error object directly posthtml/posthtml-expressions#89 (comment)
- rename Error to PluginError to not shadow actual Error - consistenly use PluginError - handle posthtml-expressions errors by not passing the error object directly - show error stack, which is very useful for this plugin posthtml/posthtml-expressions#89 (comment)
- rename Error to PluginError to not shadow actual Error - consistenly use PluginError - handle posthtml-expressions errors by not passing the error object directly - show stack which is very useful for plugins like this posthtml/posthtml-expressions#89 (comment)
Exclusively for static pages I would use posthtml-cli or parceljs |
Oops, I didn't see your comment. My build step is more complex, so posthtml-cli wouldn't be enough, and a bundler like Parcel wouldn't work either, I think, because bundlers assume an entry point (or multiple of them), which fits the model of applications, but not static sites AFAIK. I haven't seen a static site built with a bundler, though, (without a framework like Gatsby) but I'm happy to be proven wrong. 😃 I like gulp, though, as retro as it may seem. 😉 |
There is a saying in Russia "an old friend is better than two new ones" |
😄 |
Problem
I'm using posthtml-expressions with gulp-posthtml, but every time I make a mistake (e.g. try to access a property of
undefined
) gulp-posthtml throws with "Missing error message" instead of displaying a descriptive error message like it does when running posthtml directly. (This is not a problem with gulp-posthtml, read further.)Details
Eventually I found out that the "Missing error message" error was coming from plugin-error, so gulp-posthtml threw when attempting to emit an error 😄 I confirmed that this failure only happens for errors thrown specifically by posthtml-expressions. This is because plugin-error checks whether the argument is an instance of
Error
.Is this problem solvable or should I submit a PR to gulp-posthtml which fixes this in another way?
Error Logs
Issue [ Code ]
Catch any error thrown by a
vm.runInContext
call and you can verify that it's indeed not an instance ofError
.Environment
Please provide information about your environment.
The text was updated successfully, but these errors were encountered: