Catch and forward iOS exceptions to Flutter

This commit is contained in:
Ryan Heise 2020-09-28 14:25:49 +10:00
parent aaa253b133
commit 35a6e4810b
1 changed files with 49 additions and 43 deletions

View File

@ -84,6 +84,7 @@
} }
- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
@try {
NSDictionary *request = (NSDictionary *)call.arguments; NSDictionary *request = (NSDictionary *)call.arguments;
if ([@"load" isEqualToString:call.method]) { if ([@"load" isEqualToString:call.method]) {
[self load:request[@"audioSource"] result:result]; [self load:request[@"audioSource"] result:result];
@ -129,6 +130,11 @@
} else { } else {
result(FlutterMethodNotImplemented); result(FlutterMethodNotImplemented);
} }
} @catch (id exception) {
NSLog(@"Error in handleMethodCall");
FlutterError *flutterError = [FlutterError errorWithCode:@"error" message:@"Error in handleMethodCall" details:nil];
result(flutterError);
}
} }
// Untested // Untested