Revision f230a1cf deps/v8/src/d8-posix.cc
deps/v8/src/d8-posix.cc | ||
---|---|---|
245 | 245 |
if (args[3]->IsNumber()) { |
246 | 246 |
*total_timeout = args[3]->Int32Value(); |
247 | 247 |
} else { |
248 |
ThrowException(String::New("system: Argument 4 must be a number")); |
|
248 |
args.GetIsolate()->ThrowException( |
|
249 |
String::New("system: Argument 4 must be a number")); |
|
249 | 250 |
return false; |
250 | 251 |
} |
251 | 252 |
} |
... | ... | |
253 | 254 |
if (args[2]->IsNumber()) { |
254 | 255 |
*read_timeout = args[2]->Int32Value(); |
255 | 256 |
} else { |
256 |
ThrowException(String::New("system: Argument 3 must be a number")); |
|
257 |
args.GetIsolate()->ThrowException( |
|
258 |
String::New("system: Argument 3 must be a number")); |
|
257 | 259 |
return false; |
258 | 260 |
} |
259 | 261 |
} |
... | ... | |
456 | 458 |
Handle<Array> command_args; |
457 | 459 |
if (args.Length() > 1) { |
458 | 460 |
if (!args[1]->IsArray()) { |
459 |
ThrowException(String::New("system: Argument 2 must be an array")); |
|
461 |
args.GetIsolate()->ThrowException( |
|
462 |
String::New("system: Argument 2 must be an array")); |
|
460 | 463 |
return; |
461 | 464 |
} |
462 | 465 |
command_args = Handle<Array>::Cast(args[1]); |
... | ... | |
464 | 467 |
command_args = Array::New(0); |
465 | 468 |
} |
466 | 469 |
if (command_args->Length() > ExecArgs::kMaxArgs) { |
467 |
ThrowException(String::New("Too many arguments to system()")); |
|
470 |
args.GetIsolate()->ThrowException( |
|
471 |
String::New("Too many arguments to system()")); |
|
468 | 472 |
return; |
469 | 473 |
} |
470 | 474 |
if (args.Length() < 1) { |
471 |
ThrowException(String::New("Too few arguments to system()")); |
|
475 |
args.GetIsolate()->ThrowException( |
|
476 |
String::New("Too few arguments to system()")); |
|
472 | 477 |
return; |
473 | 478 |
} |
474 | 479 |
|
... | ... | |
483 | 488 |
int stdout_fds[2]; |
484 | 489 |
|
485 | 490 |
if (pipe(exec_error_fds) != 0) { |
486 |
ThrowException(String::New("pipe syscall failed.")); |
|
491 |
args.GetIsolate()->ThrowException( |
|
492 |
String::New("pipe syscall failed.")); |
|
487 | 493 |
return; |
488 | 494 |
} |
489 | 495 |
if (pipe(stdout_fds) != 0) { |
490 |
ThrowException(String::New("pipe syscall failed.")); |
|
496 |
args.GetIsolate()->ThrowException( |
|
497 |
String::New("pipe syscall failed.")); |
|
491 | 498 |
return; |
492 | 499 |
} |
493 | 500 |
|
... | ... | |
531 | 538 |
void Shell::ChangeDirectory(const v8::FunctionCallbackInfo<v8::Value>& args) { |
532 | 539 |
if (args.Length() != 1) { |
533 | 540 |
const char* message = "chdir() takes one argument"; |
534 |
ThrowException(String::New(message)); |
|
541 |
args.GetIsolate()->ThrowException(String::New(message));
|
|
535 | 542 |
return; |
536 | 543 |
} |
537 | 544 |
String::Utf8Value directory(args[0]); |
538 | 545 |
if (*directory == NULL) { |
539 | 546 |
const char* message = "os.chdir(): String conversion of argument failed."; |
540 |
ThrowException(String::New(message)); |
|
547 |
args.GetIsolate()->ThrowException(String::New(message));
|
|
541 | 548 |
return; |
542 | 549 |
} |
543 | 550 |
if (chdir(*directory) != 0) { |
544 |
ThrowException(String::New(strerror(errno))); |
|
551 |
args.GetIsolate()->ThrowException(String::New(strerror(errno)));
|
|
545 | 552 |
return; |
546 | 553 |
} |
547 | 554 |
} |
... | ... | |
550 | 557 |
void Shell::SetUMask(const v8::FunctionCallbackInfo<v8::Value>& args) { |
551 | 558 |
if (args.Length() != 1) { |
552 | 559 |
const char* message = "umask() takes one argument"; |
553 |
ThrowException(String::New(message)); |
|
560 |
args.GetIsolate()->ThrowException(String::New(message));
|
|
554 | 561 |
return; |
555 | 562 |
} |
556 | 563 |
if (args[0]->IsNumber()) { |
... | ... | |
560 | 567 |
return; |
561 | 568 |
} else { |
562 | 569 |
const char* message = "umask() argument must be numeric"; |
563 |
ThrowException(String::New(message)); |
|
570 |
args.GetIsolate()->ThrowException(String::New(message));
|
|
564 | 571 |
return; |
565 | 572 |
} |
566 | 573 |
} |
... | ... | |
616 | 623 |
mask = args[1]->Int32Value(); |
617 | 624 |
} else { |
618 | 625 |
const char* message = "mkdirp() second argument must be numeric"; |
619 |
ThrowException(String::New(message)); |
|
626 |
args.GetIsolate()->ThrowException(String::New(message));
|
|
620 | 627 |
return; |
621 | 628 |
} |
622 | 629 |
} else if (args.Length() != 1) { |
623 | 630 |
const char* message = "mkdirp() takes one or two arguments"; |
624 |
ThrowException(String::New(message)); |
|
631 |
args.GetIsolate()->ThrowException(String::New(message));
|
|
625 | 632 |
return; |
626 | 633 |
} |
627 | 634 |
String::Utf8Value directory(args[0]); |
628 | 635 |
if (*directory == NULL) { |
629 | 636 |
const char* message = "os.mkdirp(): String conversion of argument failed."; |
630 |
ThrowException(String::New(message)); |
|
637 |
args.GetIsolate()->ThrowException(String::New(message));
|
|
631 | 638 |
return; |
632 | 639 |
} |
633 | 640 |
mkdirp(*directory, mask); |
... | ... | |
637 | 644 |
void Shell::RemoveDirectory(const v8::FunctionCallbackInfo<v8::Value>& args) { |
638 | 645 |
if (args.Length() != 1) { |
639 | 646 |
const char* message = "rmdir() takes one or two arguments"; |
640 |
ThrowException(String::New(message)); |
|
647 |
args.GetIsolate()->ThrowException(String::New(message));
|
|
641 | 648 |
return; |
642 | 649 |
} |
643 | 650 |
String::Utf8Value directory(args[0]); |
644 | 651 |
if (*directory == NULL) { |
645 | 652 |
const char* message = "os.rmdir(): String conversion of argument failed."; |
646 |
ThrowException(String::New(message)); |
|
653 |
args.GetIsolate()->ThrowException(String::New(message));
|
|
647 | 654 |
return; |
648 | 655 |
} |
649 | 656 |
rmdir(*directory); |
... | ... | |
653 | 660 |
void Shell::SetEnvironment(const v8::FunctionCallbackInfo<v8::Value>& args) { |
654 | 661 |
if (args.Length() != 2) { |
655 | 662 |
const char* message = "setenv() takes two arguments"; |
656 |
ThrowException(String::New(message)); |
|
663 |
args.GetIsolate()->ThrowException(String::New(message));
|
|
657 | 664 |
return; |
658 | 665 |
} |
659 | 666 |
String::Utf8Value var(args[0]); |
... | ... | |
661 | 668 |
if (*var == NULL) { |
662 | 669 |
const char* message = |
663 | 670 |
"os.setenv(): String conversion of variable name failed."; |
664 |
ThrowException(String::New(message)); |
|
671 |
args.GetIsolate()->ThrowException(String::New(message));
|
|
665 | 672 |
return; |
666 | 673 |
} |
667 | 674 |
if (*value == NULL) { |
668 | 675 |
const char* message = |
669 | 676 |
"os.setenv(): String conversion of variable contents failed."; |
670 |
ThrowException(String::New(message)); |
|
677 |
args.GetIsolate()->ThrowException(String::New(message));
|
|
671 | 678 |
return; |
672 | 679 |
} |
673 | 680 |
setenv(*var, *value, 1); |
... | ... | |
677 | 684 |
void Shell::UnsetEnvironment(const v8::FunctionCallbackInfo<v8::Value>& args) { |
678 | 685 |
if (args.Length() != 1) { |
679 | 686 |
const char* message = "unsetenv() takes one argument"; |
680 |
ThrowException(String::New(message)); |
|
687 |
args.GetIsolate()->ThrowException(String::New(message));
|
|
681 | 688 |
return; |
682 | 689 |
} |
683 | 690 |
String::Utf8Value var(args[0]); |
684 | 691 |
if (*var == NULL) { |
685 | 692 |
const char* message = |
686 | 693 |
"os.setenv(): String conversion of variable name failed."; |
687 |
ThrowException(String::New(message)); |
|
694 |
args.GetIsolate()->ThrowException(String::New(message));
|
|
688 | 695 |
return; |
689 | 696 |
} |
690 | 697 |
unsetenv(*var); |
Also available in: Unified diff