Skip to content

Commit

Permalink
src: add error handling to uv_uptime call
Browse files Browse the repository at this point in the history
  • Loading branch information
juanarbol committed Aug 24, 2022
1 parent ab89024 commit dc09506
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/node_os.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,15 @@ static void GetTotalMemory(const FunctionCallbackInfo<Value>& args) {


static void GetUptime(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
double uptime;
int err = uv_uptime(&uptime);
if (err == 0)
args.GetReturnValue().Set(uptime);
if (err != 0) {
env->CollectUVExceptionInfo(args[args.Length() - 1], err, "uv_uptime");
return args.GetReturnValue().SetUndefined();
}

args.GetReturnValue().Set(uptime);
}


Expand Down

0 comments on commit dc09506

Please sign in to comment.