process: improve process binding
Reviewed-By: Fedor Indutny <fedor@indutny.com>
This commit is contained in:
parent
47a103a029
commit
962e651476
@ -2240,7 +2240,12 @@ static void Binding(const FunctionCallbackInfo<Value>& 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);
|
||||
|
16
test/simple/test-process-binding.js
Normal file
16
test/simple/test-process-binding.js
Normal file
@ -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");
|
Loading…
x
Reference in New Issue
Block a user