replay bgm error

Hello
My game is an action game that uses an abs system.
I've tried to have the game change to enemy music when an enemy event is activated. After the enemies are killed, the game goes back to the saved BGM.
Pretty much the process is this:
Spoiler: process
Before entering a room with an enemy, I have the game save the current bgm and bgs.
1.png

Then the enemy's event activates the battle bgm
2.png

Once all the enemies are defeated, the game recalls the saved bgm and bgs and replays it.
3.png
This works fantastically and I've never had any issues. However, while playtesting today I realized that if you save in a room with enemies then restart the game completely, there will be no saved bgm to replay so you get this error:
4.png


My question is, is there a way to do a conditional branch to check if there is a saved BGM/BGS point to replay or else just play the map music over again? I don't want to just keep playing the BGM again from the start as I don't want to annoy players.
There are many ways to achieve this:
  1. create a temporary object that is not stored in the save file and use that to determine whether or not the background music was saved;
  2. set a flag when loading a saved game and load a normal background music if the flag has been set to true, then set it to false;
  3. disallow saving the game in rooms with enemies;
  4. do not stop the background music in rooms with save points (similar to the previous one, which one is the best for you depends on how many rooms with enemies allow the player to save the game);
  5. call the normal method to play background music should the replay method throw an exception (this means using a rescue).
There are actually more ways to achieve this, you really have a lot of options here, there are no best options nor perfect ones, you just have to decide which one you are more comfortable with.
I can't believe I didn't think to disable save in enemy rooms geeze
As that's the fastest solution I'll be using that method! Thank you so much!

Original thread: https://forums.rpgmakerweb.com/threads/replay-bgm-error.119165/