[links] Some error checking
This commit is contained in:
parent
7f90e485c8
commit
b9dab3cb17
|
@ -44,11 +44,12 @@ export default class Links extends ModuleBase {
|
|||
* @returns {Promise.<String>}
|
||||
*/
|
||||
createDynamicLink(link: DynamicLink): Promise<string> {
|
||||
try {
|
||||
return getNativeModule(this).createDynamicLink(link.build());
|
||||
} catch (error) {
|
||||
return Promise.reject(error);
|
||||
if (!(link instanceof DynamicLink)) {
|
||||
throw new Error(
|
||||
`Links:createDynamicLink expects a 'DynamicLink' but got type ${typeof link}`
|
||||
);
|
||||
}
|
||||
return getNativeModule(this).createDynamicLink(link.build());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,11 +61,12 @@ export default class Links extends ModuleBase {
|
|||
link: DynamicLink,
|
||||
type?: 'SHORT' | 'UNGUESSABLE'
|
||||
): Promise<String> {
|
||||
try {
|
||||
return getNativeModule(this).createShortDynamicLink(link.build(), type);
|
||||
} catch (error) {
|
||||
return Promise.reject(error);
|
||||
if (!(link instanceof DynamicLink)) {
|
||||
throw new Error(
|
||||
`Links:createShortDynamicLink expects a 'DynamicLink' but got type ${typeof link}`
|
||||
);
|
||||
}
|
||||
return getNativeModule(this).createShortDynamicLink(link.build(), type);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue