Prevent squashing of legitimate require errors, node 0.6.x+ #197

Closed
wants to merge 1 commit into
from

Projects

None yet

4 participants

@AvianFlu

lib/bindings.js contains a double try/catch, as a workaround for the different default build directories for node 0.4.x and 0.6.x.

The problem, however, is that if one is not using node 0.4.x and one hits something akin to a linker error, the actual error will get squashed by the compatibility check, and the user will only see Cannot find module "../build/default/canvas". We encountered this issue at Nodejitsu, and we needed to bundle a modified node-canvas in a test app before we even knew what, specifically, was failing.

This patch adds a simplistic test, saving the original error, and throwing the original instead in the event that the error from the 0.4.x require begins with Cannot find module. Testing the error message with a regex is a bit of a hack, but it seemed significantly saner than asking you guys to drop 0.4.x support. :)

@AvianFlu AvianFlu [fix] Prevent squashing of require errors, node 0.6.x+
Because of the way the double try/catch was set up, a user using node 0.6.x or
0.8.x will only ever see "Cannot find module ../build/default/canvas" in the
event of a misconfiguration or linker error.  This makes the compatibility
check throw the original error, if "../build/default/canvas" cannot be found.
6de31e0
@rauchg
rauchg commented Aug 10, 2012

I'm actually down for throwing out 0.4 support.

@AvianFlu

I'd have absolutely no problem with that. :)

@TooTallNate

node-bindings does pretty much this as well if you wanna use a submodule.

@tj
tj commented Aug 10, 2012

hell yeah screw 0.4.x haha, doesn't matter to me, there's nothing overly significant lately feature-wise so people can always use older versions if they really need to

@tj tj added a commit that closed this pull request Oct 25, 2012
@tj tj remove old 0.4.x binding support. Closes #197 64af9b2
@tj tj closed this in 64af9b2 Oct 25, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment