js: Throw GObject.NotImplementedError when requiring overriding
Since version 1.50.0, gjs defines GObject.NotImplementedError for throwing errors when a "virtual" method that requires a subclass implementation is not defined. So use this instead of a generic JS Error in such cases. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/549
This commit is contained in:
@ -79,7 +79,7 @@ class BaseIcon extends St.Bin {
|
||||
// This can be overridden by a subclass, or by the createIcon
|
||||
// parameter to _init()
|
||||
createIcon(size) {
|
||||
throw new Error('no implementation of createIcon in ' + this);
|
||||
throw new GObject.NotImplementedError(`createIcon in ${this.constructor.name}`);
|
||||
}
|
||||
|
||||
setIconSize(size) {
|
||||
@ -416,7 +416,8 @@ var IconGrid = GObject.registerClass({
|
||||
|
||||
animatePulse(animationDirection) {
|
||||
if (animationDirection != AnimationDirection.IN)
|
||||
throw new Error("Pulse animation only implements 'in' animation direction");
|
||||
throw new GObject.NotImplementedError("Pulse animation only implements " +
|
||||
"'in' animation direction");
|
||||
|
||||
this._cancelAnimation();
|
||||
|
||||
|
Reference in New Issue
Block a user