From 4676d0dfd9d3c629e9a4a926001632bcbe2066e8 Mon Sep 17 00:00:00 2001 From: Pascal Mugnier Date: Fri, 13 Apr 2018 07:41:11 +0200 Subject: [PATCH] SONAR-10564 Exception when opening rule description in Google Chrome --- .../src/main/js/app/components/RecentHistory.js | 12 ++++++++++-- .../src/main/js/components/workspace/models/items.js | 6 +++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/server/sonar-web/src/main/js/app/components/RecentHistory.js b/server/sonar-web/src/main/js/app/components/RecentHistory.js index 1bc7d308621..23e4ff59f20 100644 --- a/server/sonar-web/src/main/js/app/components/RecentHistory.js +++ b/server/sonar-web/src/main/js/app/components/RecentHistory.js @@ -51,13 +51,21 @@ export default class RecentHistory { static set(newHistory /*: History */) /*: void */ { if (window.localStorage) { - window.localStorage.setItem(STORAGE_KEY, JSON.stringify(newHistory)); + try { + window.localStorage.setItem(STORAGE_KEY, JSON.stringify(newHistory)); + } catch (e) { + /* Fail silently*/ + } } } static clear() /*: void */ { if (window.localStorage) { - window.localStorage.removeItem(STORAGE_KEY); + try { + window.localStorage.removeItem(STORAGE_KEY); + } catch (e) { + /* Fail silently*/ + } } } diff --git a/server/sonar-web/src/main/js/components/workspace/models/items.js b/server/sonar-web/src/main/js/components/workspace/models/items.js index 655b836da8b..d619d8d72ff 100644 --- a/server/sonar-web/src/main/js/components/workspace/models/items.js +++ b/server/sonar-web/src/main/js/components/workspace/models/items.js @@ -31,7 +31,11 @@ export default Backbone.Collection.extend({ save() { const dump = JSON.stringify(this.toJSON()); - window.localStorage.setItem(STORAGE_KEY, dump); + try { + window.localStorage.setItem(STORAGE_KEY, dump); + } catch (e) { + /* Fail silently*/ + } }, load() { -- 2.39.5