From 1ec3f47e7852af6ab7b422839cf37fcaa21a4dca Mon Sep 17 00:00:00 2001 From: Kevin Thomas Date: Thu, 18 Jul 2019 12:38:32 +0530 Subject: [PATCH] Fix #7087: Add log for "contains no units" SyntaxError (#7157) * Fixes #2197 and #2195 * fix e2e error (library) * Use URL as constants * Constants in all caps * Fix linting issue * adds log for #7087 * address review comment * address review comment * log earlierInput --- .../directives/NumberWithUnitsValidationService.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/extensions/interactions/NumberWithUnits/directives/NumberWithUnitsValidationService.ts b/extensions/interactions/NumberWithUnits/directives/NumberWithUnitsValidationService.ts index 0b4c1926ad25..64364f3dacd7 100644 --- a/extensions/interactions/NumberWithUnits/directives/NumberWithUnitsValidationService.ts +++ b/extensions/interactions/NumberWithUnits/directives/NumberWithUnitsValidationService.ts @@ -72,8 +72,17 @@ oppia.factory('NumberWithUnitsValidationService', [ } var earlierInputString = earlierInput.toMathjsCompatibleString(); var laterInputString = laterInput.toMathjsCompatibleString(); - return math.unit(laterInputString).equals(math.unit( - earlierInputString)); + try { + return math.unit(laterInputString).equals(math.unit( + earlierInputString)); + } catch (e) { + var additionalInfo = ( + '\nlaterInput: ' + JSON.stringify(laterInput.toDict()) + + '\nearlierInput: ' + JSON.stringify(earlierInput.toDict()) + ); + e.message += additionalInfo; + throw e; + } }; var ranges = [];