-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
v8: add type check to make failed calls visible #1652
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,13 @@ void GetHeapStatistics(const FunctionCallbackInfo<Value>& args) { | |
|
||
|
||
void SetFlagsFromString(const FunctionCallbackInfo<Value>& args) { | ||
Environment* env = Environment::GetCurrent(args); | ||
|
||
if (args.Length() < 1) | ||
return env->ThrowTypeError("v8 flag is required"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aren't There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that might be right, but There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alright, nevermind then. If the existing code uses |
||
if (!args[0]->IsString()) | ||
return env->ThrowTypeError("v8 flag must be a string"); | ||
|
||
String::Utf8Value flags(args[0]); | ||
V8::SetFlagsFromString(*flags, flags.length()); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
var common = require('../common'); | ||
var assert = require('assert'); | ||
var v8 = require('v8'); | ||
|
||
assert.throws(function() {v8.setFlagsFromString(1)}, TypeError); | ||
assert.throws(function() {v8.setFlagsFromString()}, TypeError); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe make that
args.Length() < 1
? Or simply drop it and rely on theargs[0]->IsString()
check below to catch it.