From 2f0bbdba108d26c6cc07641b753ed3eb6917b5bc Mon Sep 17 00:00:00 2001 From: Fredrik Roubert Date: Tue, 6 Nov 2012 16:14:28 +0000 Subject: [PATCH] JS: Replace hardcoded exception string with proper enum value, as declared. Review URL: https://codereview.appspot.com/6814093 --- javascript/i18n/phonenumbers/phonenumberutil.js | 2 +- javascript/i18n/phonenumbers/phonenumberutil_test.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/javascript/i18n/phonenumbers/phonenumberutil.js b/javascript/i18n/phonenumbers/phonenumberutil.js index a73e3c1ea..28fdee251 100644 --- a/javascript/i18n/phonenumbers/phonenumberutil.js +++ b/javascript/i18n/phonenumbers/phonenumberutil.js @@ -3628,7 +3628,7 @@ i18n.phonenumbers.PhoneNumberUtil.prototype.parseHelper_ = throw i18n.phonenumbers.Error.NOT_A_NUMBER; } else if (numberToParse.length > i18n.phonenumbers.PhoneNumberUtil.MAX_INPUT_STRING_LENGTH_) { - throw 'The string supplied was too long to parse'; + throw i18n.phonenumbers.Error.TOO_LONG; } /** @type {!goog.string.StringBuffer} */ diff --git a/javascript/i18n/phonenumbers/phonenumberutil_test.js b/javascript/i18n/phonenumbers/phonenumberutil_test.js index 62359e416..83a86f64f 100644 --- a/javascript/i18n/phonenumbers/phonenumberutil_test.js +++ b/javascript/i18n/phonenumbers/phonenumberutil_test.js @@ -2210,7 +2210,7 @@ function testParseMaliciousInput() { } catch (e) { // Expected this exception. assertEquals('Wrong error type stored in exception.', - 'The string supplied was too long to parse', + i18n.phonenumbers.Error.TOO_LONG, e); } /** @type {!goog.string.StringBuffer} */ @@ -2226,7 +2226,7 @@ function testParseMaliciousInput() { } catch (e) { // Expected this exception. assertEquals('Wrong error type stored in exception.', - 'The string supplied was too long to parse', + i18n.phonenumbers.Error.TOO_LONG, e); } }