From c84ccfc73513797bed94a92a26c303d74f2eff3c Mon Sep 17 00:00:00 2001 From: lilia Date: Sat, 7 Feb 2015 16:19:04 -1000 Subject: [PATCH] Wrap model phonenumber validation in try/catch --- js/models/conversations.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/js/models/conversations.js b/js/models/conversations.js index 3dc8b8e3..a7c7039e 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -47,15 +47,18 @@ // hack if (this.get('type') === 'private') { - this.id = libphonenumber.util.verifyNumber(this.id); - var number = libphonenumber.util.splitCountryCode(this.id); - - this.set({ - e164_number: this.id, - national_number: '' + number.national_number, - international_number: '' + number.country_code + number.national_number - }); + try { + this.id = libphonenumber.util.verifyNumber(this.id); + var number = libphonenumber.util.splitCountryCode(this.id); + this.set({ + e164_number: this.id, + national_number: '' + number.national_number, + international_number: '' + number.country_code + number.national_number + }); + } catch(ex) { + return ex; + } } },