X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Futils%2FgameStorage.js;h=59efb43af88338a05e523ef7d6f112d50194a256;hp=92db29915abf33081e61e6571c07f368ae72e9ae;hb=c292ebb2a014646005b01e27253c162f1d639387;hpb=afde76668963c4d0d96002fcae2ebabb9acf81e4 diff --git a/client/src/utils/gameStorage.js b/client/src/utils/gameStorage.js index 92db2991..59efb43a 100644 --- a/client/src/utils/gameStorage.js +++ b/client/src/utils/gameStorage.js @@ -43,7 +43,7 @@ export const GameStorage = { // Optional callback to get error status add: function(game, callback) { dbOperation((err,db) => { - if (err) { + if (!!err) { callback("error"); return; } @@ -51,6 +51,9 @@ export const GameStorage = { transaction.oncomplete = function() { callback(); //everything's fine }; + transaction.onerror = function(err) { + callback(err); //duplicate key error (most likely) + }; let objectStore = transaction.objectStore("games"); objectStore.add(game); });