From: Jackson Tian Date: Fri, 1 Aug 2014 11:26:09 +0000 (+0800) Subject: process: improve process binding X-Git-Tag: upstream/0.12.0~90 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=962e651476ce2035ce6e15eff5abd0f9c54e039c;p=platform%2Fupstream%2Fnodejs.git process: improve process binding Reviewed-By: Fedor Indutny --- diff --git a/src/node.cc b/src/node.cc index 61a5cfd..f3409dc 100644 --- a/src/node.cc +++ b/src/node.cc @@ -2240,7 +2240,12 @@ static void Binding(const FunctionCallbackInfo& args) { DefineJavaScript(env, exports); cache->Set(module, exports); } else { - return env->ThrowError("No such module"); + char errmsg[1024]; + snprintf(errmsg, + sizeof(errmsg), + "No such module: %s", + *module_v); + return env->ThrowError(errmsg); } args.GetReturnValue().Set(exports); diff --git a/test/simple/test-process-binding.js b/test/simple/test-process-binding.js new file mode 100644 index 0000000..c803a80 --- /dev/null +++ b/test/simple/test-process-binding.js @@ -0,0 +1,16 @@ +var assert = require('assert'); + +assert.throws( + function() { + process.binding('test'); + }, + /No such module: test/ +); + +assert.doesNotThrow(function () { + process.binding('buffer'); +}, function(err) { + if ( (err instanceof Error) ) { + return true; + } +}, "unexpected error");