add QuotaExceededError exception handling to saveConfig function
authorJoonghun Park <jh718.park@samsung.com>
Mon, 28 Oct 2013 06:59:23 +0000 (15:59 +0900)
committerJoonghun Park <jh718.park@samsung.com>
Mon, 28 Oct 2013 07:03:36 +0000 (16:03 +0900)
[title] add QuotaExceededError exception handling to saveConfig function

Change-Id: Idf6f1860ae1ba3caa08e7d133bda82693fe3df00

js/app.js

index 86fe762..1836776 100644 (file)
--- a/js/app.js
+++ b/js/app.js
@@ -144,7 +144,12 @@ var ExercisePlanner = function () {
         * (use localStorage)
         */
        ExercisePlanner.prototype.saveConfig = function () {
-               localStorage.setItem('config', JSON.stringify(this.config));
+               try {
+                       localStorage.setItem('config', JSON.stringify(this.config));
+               } catch (e) {
+                       if (e.code === 22) //QuotaExceededError
+                               this.ui.showErrors([{name: 'Not enough memory. Please remove unnecessary files'}]);
+               }
        };
 
        ExercisePlanner.prototype.stopTraining = function () {