Closed silvenon closed 4 years ago
@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.
Repro: https://github.com/silvenon/repro/tree/posthtml-expressions-error
+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 gulp
?
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.
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?
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. π
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.