avoid call resolve on createShortDynamicLink error and remove try/catch in the js wrapper module

This commit is contained in:
Omer Levy 2018-01-12 16:39:18 +02:00
parent 3dacb35291
commit 8d7152fe70
2 changed files with 11 additions and 17 deletions

View File

@ -161,9 +161,11 @@ RCT_EXPORT_METHOD(createShortDynamicLink: (NSDictionary *) metadata resolver:(RC
NSLog(@"create short dynamic link failure %@", [error localizedDescription]); NSLog(@"create short dynamic link failure %@", [error localizedDescription]);
reject(@"links/failure", @"Failed to create Short Dynamic Link", error); reject(@"links/failure", @"Failed to create Short Dynamic Link", error);
} }
else {
NSURL *shortLink = shortURL; NSURL *shortLink = shortURL;
NSLog(@"created short dynamic link: %@", shortLink.absoluteString); NSLog(@"created short dynamic link: %@", shortLink.absoluteString);
resolve(shortLink.absoluteString); resolve(shortLink.absoluteString);
}
}]; }];
} }
@catch(NSException * e) { @catch(NSException * e) {

View File

@ -108,13 +108,9 @@ export default class Links extends ModuleBase {
* @returns {Promise.<String>} * @returns {Promise.<String>}
*/ */
createDynamicLink(parameters: Object = {}): Promise<string> { createDynamicLink(parameters: Object = {}): Promise<string> {
try {
checkForMandatoryParameters(parameters); checkForMandatoryParameters(parameters);
validateParameters(parameters); validateParameters(parameters);
return getNativeModule(this).createDynamicLink(parameters); return getNativeModule(this).createDynamicLink(parameters);
} catch (error) {
return Promise.reject(error);
}
} }
/** /**
@ -123,13 +119,9 @@ export default class Links extends ModuleBase {
* @returns {Promise.<String>} * @returns {Promise.<String>}
*/ */
createShortDynamicLink(parameters: Object = {}): Promise<String> { createShortDynamicLink(parameters: Object = {}): Promise<String> {
try {
checkForMandatoryParameters(parameters); checkForMandatoryParameters(parameters);
validateParameters(parameters); validateParameters(parameters);
return getNativeModule(this).createShortDynamicLink(parameters); return getNativeModule(this).createShortDynamicLink(parameters);
} catch (error) {
return Promise.reject(error);
}
} }
} }