Skip to content

Commit 65be29b

Browse files
ArchezNathanWalker
authored andcommitted
fix: prevent crashes during onuncaughterror (#141)
1 parent c580098 commit 65be29b

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

NativeScript/runtime/NativeScriptException.mm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,12 @@
4343
Local<Object> thiz = Object::New(isolate);
4444
Local<Value> args[] = { error };
4545
Local<Value> result;
46+
TryCatch tc(isolate);
4647
success = errorHandlerFunc->Call(context, thiz, 1, args).ToLocal(&result);
48+
if (tc.HasCaught()) {
49+
tns::LogError(isolate, tc);
50+
}
51+
4752
tns::Assert(success, isolate);
4853
}
4954

NativeScript/runtime/Runtime.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,10 @@
159159
if (AppPackageJson == nil) {
160160
NSString* packageJsonPath = [[NSString stringWithUTF8String:RuntimeConfig.ApplicationPath.c_str()] stringByAppendingPathComponent:@"package.json"];
161161
NSData* data = [NSData dataWithContentsOfFile:packageJsonPath];
162-
AppPackageJson = @{};
163162
if (data) {
164163
NSError* error = nil;
165-
AppPackageJson = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
164+
NSDictionary* dict = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
165+
AppPackageJson = [[NSDictionary alloc] initWithDictionary:dict];
166166
}
167167
}
168168

0 commit comments

Comments
 (0)