There are some exceptions in my game I can silently handle and then there are some that bring the game into an invalid state I can’t recover from (plus probably at least a few I didn’t even think of that might happen unexpectedly).
When an exception that brings the game into an invalid state occurs, I’d like to present the user with a short dialog box what went wrong and then shut down the game.
Problem is, I really can’t find a way to catch all unhandled exceptions.
In the end, Unity seems to handle all exceptions in some kind of way, which is why the [UnhandledExceptionEvent](http://(AppDomain.UnhandledException Event (System) | Microsoft Learn) doesn’t catch anything.
I know about LogCallback, which is the only thing that comes up in Google as some kind of solution for catching unhandled exceptions in Unity. But that’s not practical at all. First, it lacks a lot of information because you don’t even get the exception instance itself and second and even more important, it catches all logged exceptions, which includes the exceptions my code catches, logs and handles/recovers from in a try/catch block as well as those that aren’t handled by my code and bubble up. This means I cannot tell at all if an exception that comes up in LogCallback was handled by my code or not (unless I stop logging exceptions I can recover from but that can’t be the solution).
I nearly can’t believe there’s nothing as basic as a hook to just attach to every exception that wasn’t handled by my code.
Am I overlooking something?
Thanks very much!