From: Pascal Mugnier Date: Fri, 13 Apr 2018 10:43:54 +0000 (+0200) Subject: SONAR-10564 Exception when opening rule description in Google Chrome (#3169) X-Git-Tag: 6.7.4~16 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b333667fb4c5f3893bf8aaa94a22310919eda39a;p=sonarqube.git SONAR-10564 Exception when opening rule description in Google Chrome (#3169) --- 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..64da44492ec 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..9a82d7ebbf7 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() {