Skip to content

Commit

Permalink
fix: prevent crashes during onuncaughterror (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
Archez authored and NathanWalker committed Mar 7, 2022
1 parent c580098 commit 65be29b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions NativeScript/runtime/NativeScriptException.mm
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@
Local<Object> thiz = Object::New(isolate);
Local<Value> args[] = { error };
Local<Value> result;
TryCatch tc(isolate);
success = errorHandlerFunc->Call(context, thiz, 1, args).ToLocal(&result);
if (tc.HasCaught()) {
tns::LogError(isolate, tc);
}

tns::Assert(success, isolate);
}

Expand Down
4 changes: 2 additions & 2 deletions NativeScript/runtime/Runtime.mm
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,10 @@
if (AppPackageJson == nil) {
NSString* packageJsonPath = [[NSString stringWithUTF8String:RuntimeConfig.ApplicationPath.c_str()] stringByAppendingPathComponent:@"package.json"];
NSData* data = [NSData dataWithContentsOfFile:packageJsonPath];
AppPackageJson = @{};
if (data) {
NSError* error = nil;
AppPackageJson = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
NSDictionary* dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
AppPackageJson = [[NSDictionary alloc] initWithDictionary:dict];
}
}

Expand Down

0 comments on commit 65be29b

Please sign in to comment.