Merge pull request #267 from juliandescottes/uncaught-errors-crash-nodewebkit
#261 replaced throw by console.error for recoverable errors
This commit is contained in:
commit
29e205d441
7 changed files with 22 additions and 27 deletions
|
@ -98,7 +98,7 @@
|
|||
this.closeDrawer_();
|
||||
} else {
|
||||
this.closeDrawer_();
|
||||
throw 'File is not an image : ' + file.type;
|
||||
console.error('File is not an image : ' + file.type);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
if (this.frames[index]) {
|
||||
this.frames.splice(index, 1);
|
||||
} else {
|
||||
throw 'Invalid index in removeFrameAt : ' + index + ' (size : ' + this.size() + ')';
|
||||
console.error('Invalid index in removeFrameAt : %s (size : %s)', index, this.size());
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -72,9 +72,7 @@
|
|||
this.frames[toIndex] = fromFrame;
|
||||
this.frames[fromIndex] = toFrame;
|
||||
} else {
|
||||
console.log('frames', this.frames);
|
||||
console.log('fromIndex', fromIndex, 'toIndex', toIndex);
|
||||
throw 'Frame not found in moveFrameAt';
|
||||
console.error('Frame not found in moveFrameAt (from %s, to %s)', fromIndex, toIndex);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -89,7 +87,7 @@
|
|||
var clone = frame.clone();
|
||||
this.addFrameAt(clone, index);
|
||||
} else {
|
||||
throw 'Frame not found in duplicateFrameAt';
|
||||
console.error('Frame not found in duplicateFrameAt (at %s)', index);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -85,9 +85,6 @@
|
|||
this.currentSelection.fillSelectionFromFrame(this.piskelController.getCurrentFrame());
|
||||
this.erase();
|
||||
}
|
||||
else {
|
||||
throw "Bad state for CUT callback in SelectionManager";
|
||||
}
|
||||
};
|
||||
|
||||
ns.SelectionManager.prototype.paste = function() {
|
||||
|
@ -128,8 +125,6 @@
|
|||
ns.SelectionManager.prototype.copy = function() {
|
||||
if(this.currentSelection && this.piskelController.getCurrentFrame()) {
|
||||
this.currentSelection.fillSelectionFromFrame(this.piskelController.getCurrentFrame());
|
||||
} else {
|
||||
throw "Bad state for CUT callback in SelectionManager";
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -140,7 +135,7 @@
|
|||
if(selection) {
|
||||
this.currentSelection = selection;
|
||||
} else {
|
||||
throw "No selection set in SelectionManager";
|
||||
console.error("No selection provided to SelectionManager");
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -150,9 +145,8 @@
|
|||
ns.SelectionManager.prototype.onSelectionMoved_ = function(evt, colDiff, rowDiff) {
|
||||
if(this.currentSelection) {
|
||||
this.currentSelection.move(colDiff, rowDiff);
|
||||
}
|
||||
else {
|
||||
throw "Bad state: No currentSelection set when trying to move it in SelectionManager";
|
||||
} else {
|
||||
console.error("Bad state: No currentSelection set when trying to move it in SelectionManager");
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
|
|
@ -92,19 +92,23 @@
|
|||
var onPiskelLoadedCb = this.onPiskelLoaded_.bind(this, index, snapshotIndex);
|
||||
this.deserializer.deserialize(serializedPiskel, onPiskelLoadedCb);
|
||||
}
|
||||
} catch (e) {
|
||||
window.console.error("[CRITICAL ERROR] : Unable to load a history state.");
|
||||
if (typeof e === "string") {
|
||||
window.console.error(e);
|
||||
} else {
|
||||
window.console.error(e.message);
|
||||
window.console.error(e.stack);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("[CRITICAL ERROR] : Unable to load a history state.");
|
||||
this.logError_(error);
|
||||
this.stateQueue = [];
|
||||
this.currentIndex = -1;
|
||||
}
|
||||
};
|
||||
|
||||
ns.HistoryService.prototype.logError_ = function (error) {
|
||||
if (typeof error === "string") {
|
||||
console.error(error);
|
||||
} else {
|
||||
console.error(error.message);
|
||||
console.error(error.stack);
|
||||
}
|
||||
};
|
||||
|
||||
ns.HistoryService.prototype.getSnapshotFromState_ = function (stateIndex) {
|
||||
var state = this.stateQueue[stateIndex];
|
||||
var piskelSnapshot = state.piskel;
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
var ns = $.namespace("pskl.service");
|
||||
|
||||
ns.LocalStorageService = function (piskelController) {
|
||||
|
||||
if(piskelController === undefined) {
|
||||
throw "Bad LocalStorageService initialization: <undefined piskelController>";
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
if (reader) {
|
||||
reader.read();
|
||||
} else {
|
||||
throw 'Could not find reader for file : ' + file.name;
|
||||
console.error('Could not find reader for file : %s', file.name);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@
|
|||
checkKeyValidity_ : function(key) {
|
||||
if(!(key in this.KEY_TO_DEFAULT_VALUE_MAP_)) {
|
||||
// TODO(grosbouddha): Define error catching strategy and throw exception from here.
|
||||
console.log("UserSettings key <"+ key +"> not find in supported keys.");
|
||||
console.error("UserSettings key <"+ key +"> not found in supported keys.");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue