mirror of
https://github.com/piskelapp/piskel.git
synced 2023-08-10 21:12:52 +03:00
#261 replaced throw by console.error for recoverable errors
This commit is contained in:
parent
d1b12a07ac
commit
1f5272415c
|
@ -98,7 +98,7 @@
|
||||||
this.closeDrawer_();
|
this.closeDrawer_();
|
||||||
} else {
|
} else {
|
||||||
this.closeDrawer_();
|
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]) {
|
if (this.frames[index]) {
|
||||||
this.frames.splice(index, 1);
|
this.frames.splice(index, 1);
|
||||||
} else {
|
} 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[toIndex] = fromFrame;
|
||||||
this.frames[fromIndex] = toFrame;
|
this.frames[fromIndex] = toFrame;
|
||||||
} else {
|
} else {
|
||||||
console.log('frames', this.frames);
|
console.error('Frame not found in moveFrameAt (from %s, to %s)', fromIndex, toIndex);
|
||||||
console.log('fromIndex', fromIndex, 'toIndex', toIndex);
|
|
||||||
throw 'Frame not found in moveFrameAt';
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -89,7 +87,7 @@
|
||||||
var clone = frame.clone();
|
var clone = frame.clone();
|
||||||
this.addFrameAt(clone, index);
|
this.addFrameAt(clone, index);
|
||||||
} else {
|
} 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.currentSelection.fillSelectionFromFrame(this.piskelController.getCurrentFrame());
|
||||||
this.erase();
|
this.erase();
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
throw "Bad state for CUT callback in SelectionManager";
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ns.SelectionManager.prototype.paste = function() {
|
ns.SelectionManager.prototype.paste = function() {
|
||||||
|
@ -128,8 +125,6 @@
|
||||||
ns.SelectionManager.prototype.copy = function() {
|
ns.SelectionManager.prototype.copy = function() {
|
||||||
if(this.currentSelection && this.piskelController.getCurrentFrame()) {
|
if(this.currentSelection && this.piskelController.getCurrentFrame()) {
|
||||||
this.currentSelection.fillSelectionFromFrame(this.piskelController.getCurrentFrame());
|
this.currentSelection.fillSelectionFromFrame(this.piskelController.getCurrentFrame());
|
||||||
} else {
|
|
||||||
throw "Bad state for CUT callback in SelectionManager";
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -140,7 +135,7 @@
|
||||||
if(selection) {
|
if(selection) {
|
||||||
this.currentSelection = selection;
|
this.currentSelection = selection;
|
||||||
} else {
|
} 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) {
|
ns.SelectionManager.prototype.onSelectionMoved_ = function(evt, colDiff, rowDiff) {
|
||||||
if(this.currentSelection) {
|
if(this.currentSelection) {
|
||||||
this.currentSelection.move(colDiff, rowDiff);
|
this.currentSelection.move(colDiff, rowDiff);
|
||||||
}
|
} else {
|
||||||
else {
|
console.error("Bad state: No currentSelection set when trying to move it in SelectionManager");
|
||||||
throw "Bad state: No currentSelection set when trying to move it in SelectionManager";
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -92,19 +92,23 @@
|
||||||
var onPiskelLoadedCb = this.onPiskelLoaded_.bind(this, index, snapshotIndex);
|
var onPiskelLoadedCb = this.onPiskelLoaded_.bind(this, index, snapshotIndex);
|
||||||
this.deserializer.deserialize(serializedPiskel, onPiskelLoadedCb);
|
this.deserializer.deserialize(serializedPiskel, onPiskelLoadedCb);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (error) {
|
||||||
window.console.error("[CRITICAL ERROR] : Unable to load a history state.");
|
console.error("[CRITICAL ERROR] : Unable to load a history state.");
|
||||||
if (typeof e === "string") {
|
this.logError_(error);
|
||||||
window.console.error(e);
|
|
||||||
} else {
|
|
||||||
window.console.error(e.message);
|
|
||||||
window.console.error(e.stack);
|
|
||||||
}
|
|
||||||
this.stateQueue = [];
|
this.stateQueue = [];
|
||||||
this.currentIndex = -1;
|
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) {
|
ns.HistoryService.prototype.getSnapshotFromState_ = function (stateIndex) {
|
||||||
var state = this.stateQueue[stateIndex];
|
var state = this.stateQueue[stateIndex];
|
||||||
var piskelSnapshot = state.piskel;
|
var piskelSnapshot = state.piskel;
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
var ns = $.namespace("pskl.service");
|
var ns = $.namespace("pskl.service");
|
||||||
|
|
||||||
ns.LocalStorageService = function (piskelController) {
|
ns.LocalStorageService = function (piskelController) {
|
||||||
|
|
||||||
if(piskelController === undefined) {
|
if(piskelController === undefined) {
|
||||||
throw "Bad LocalStorageService initialization: <undefined piskelController>";
|
throw "Bad LocalStorageService initialization: <undefined piskelController>";
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
if (reader) {
|
if (reader) {
|
||||||
reader.read();
|
reader.read();
|
||||||
} else {
|
} 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) {
|
checkKeyValidity_ : function(key) {
|
||||||
if(!(key in this.KEY_TO_DEFAULT_VALUE_MAP_)) {
|
if(!(key in this.KEY_TO_DEFAULT_VALUE_MAP_)) {
|
||||||
// TODO(grosbouddha): Define error catching strategy and throw exception from here.
|
// 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 New Issue
Block a user