Skip to content

Commit

Permalink
Clean up after Nan::ThrowError and make returns consistent
Browse files Browse the repository at this point in the history
Fixes chjj#102
  • Loading branch information
Tyriar committed Jul 7, 2017
1 parent 7144d71 commit e808093
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/win/pty.cc
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ static NAN_METHOD(PtyStartProcess) {
|| !info[5]->IsNumber() // rows
|| !info[6]->IsBoolean()) // debug
{
return Nan::ThrowError(
"Usage: pty.startProcess(file, cmdline, env, cwd, cols, rows, debug)");
Nan::ThrowError("Usage: pty.startProcess(file, cmdline, env, cwd, cols, rows, debug)");
return;
}

std::stringstream why;
Expand Down Expand Up @@ -204,6 +204,7 @@ static NAN_METHOD(PtyStartProcess) {
std::string msg_(msg.begin(), msg.end());
why << "Error creating WinPTY config: " << msg_;
Nan::ThrowError(why.str().c_str());
goto cleanup;
}
winpty_error_free(error_ptr);
winpty_config_set_initial_size(winpty_config, cols, rows);
Expand All @@ -230,6 +231,7 @@ static NAN_METHOD(PtyStartProcess) {
if(!spawnSuccess) {
why << "Unable to start terminal process.";
Nan::ThrowError(why.str().c_str());
goto cleanup;
}

// Pty object values.
Expand Down Expand Up @@ -259,7 +261,7 @@ static NAN_METHOD(PtyStartProcess) {
delete cmdline;
delete cwd;

return info.GetReturnValue().Set(marshal);
info.GetReturnValue().Set(marshal);
}

/*
Expand All @@ -274,7 +276,8 @@ static NAN_METHOD(PtyResize) {
|| !info[1]->IsNumber() // cols
|| !info[2]->IsNumber()) // rows
{
return Nan::ThrowError("Usage: pty.resize(pid, cols, rows)");
Nan::ThrowError("Usage: pty.resize(pid, cols, rows)");
return;
}

int handle = info[0]->Int32Value();
Expand All @@ -301,7 +304,8 @@ static NAN_METHOD(PtyKill) {
|| !info[0]->IsNumber() // pid
|| !info[1]->IsNumber()) // innerPidHandle
{
return Nan::ThrowError("Usage: pty.kill(pid, innerPidHandle)");
Nan::ThrowError("Usage: pty.kill(pid, innerPidHandle)");
return;
}

int handle = info[0]->Int32Value();
Expand Down

0 comments on commit e808093

Please sign in to comment.