Kylemc1413 / SongCore

A plugin for handling custom song additions in Beat Saber.
MIT License
86 stars 47 forks source link

Show error and catch exceptions when failing to load beatmap #129

Closed Meivyn closed 10 months ago

Meivyn commented 11 months ago

This allows SongCore to catch exceptions that may happen when loading beatmaps, which it wasn't doing before. This makes sure nothing breaks when an exception happens, and also replaces the old behavior of having an infinite loading with a proper error message.

This error message is based on the stack trace currently. I don't know if there's something more reliable to use, and anyway is still better than nothing. It'll show the default error message when the error cause is unknown.

Currently, custom error messages are unlikely to happen, I haven't found any map yet that fails the regex parsing. It's just in case. And the characteristic message may become more relevant with my next PR which is gonna fix a serious issue that may result in player data being wiped.

Here is how it looks in-game.

image

This PR also introduces a needed fix for an issue with transpilers that would previously been worked around by inserting a Nop instruction after a Leave one. This, however, didn't work in all cases and didn't with mine. This should allow @Aeroluna to remove those workarounds in CustomJSONData.

I plan to update HarmonyX as soon as a fix is implemented for this issue.