Throw an error for bad scene keys

If you use a bad scene key, Phaser just ignores it. IMHO this is not super helpful, so

const { getScene } = Phaser.Scenes.SceneManager.prototype;

Phaser.Scenes.SceneManager.prototype.getScene = function (key) {
  const result = getScene.call(this, key);

  if (!result) throw new Error('No such scene: ' + key);

  return result;
};
1 Like