From b9dab3cb175daae41833f33d6315ef8c5b8bb030 Mon Sep 17 00:00:00 2001 From: Chris Bianca Date: Fri, 23 Mar 2018 13:26:20 +0000 Subject: [PATCH] [links] Some error checking --- lib/modules/links/index.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/modules/links/index.js b/lib/modules/links/index.js index bb128399..a926b182 100644 --- a/lib/modules/links/index.js +++ b/lib/modules/links/index.js @@ -44,11 +44,12 @@ export default class Links extends ModuleBase { * @returns {Promise.} */ createDynamicLink(link: DynamicLink): Promise { - 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 { - 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); } /**