Why no error handling?

Since I have begun to write my own plugin the last weeks, I have seen many tutorials and plugins made by others too. But practically none of the are using try-catch error handling, what confused me.
On my work, an unhandled exception is a most common problem. We try to fit all functions with error handling to hold a program on a defined state and get accurate error messages.
Well, I'm new on plugin writing and JavaScript at all so I don't know why nobody makes use of JS try-catch option with stack trace output. I know there could be some performance issues, but I have made some tests with and without this error handling and there was nearly no difference.


Kind regards,
Purzelkater
because JS is not so good for error backtrace. and everyone have their OWN way's to handles the error backtrace honestly.


For myself I had condition where's it's permit to throw error call if someone mess a plugin or I use Console.log for make sure everything's works ect.
There is a global exception handler in the DataManager that catches any error and prints a stacktrace, so I kind of just let that handle it.


I don't make any effort to try to keep the game going in the case of some exceptional behavior for example.


If the game crashes...then it should be reported and resolved.


Do you have a particular example in your plugin development where you would found cases where you would like to catch and handle yourself, rather than just letting the game crash?
Well, as you are right, practically it would not be necessary to use special error handling. Finally it's just a game and a plugin should work in common situations.
But because I have lerned to use try-catch over years now, I was woundering if there is an important reason not to use this on MV plugins too. So it was more like a design question in generally.
I don't know about others, but under normal circumstances, my expectation is for the game to crash if an exception occurs, so I just let it crash.


It's not the most effective way to handle exceptions, especially since you don't get a "useful" error message (at best, you would just get a standard exception message like divide by zero, no such method, etc), but I have the line number that it crashed and usually it's probably pretty obvious why it crashed.


If there are cases where crashing might actually cause problems if I don't handle the crash, then I would build in some special handling.


For example if you were making a database transaction and it failed part way, I'd want to rollback.
I don't know about others, but under normal circumstances, my expectation is for the game to crash if an exception occurs, so I just let it crash.

The same here.


Errors aren't supposed to happen, and the crash points that there is something wrong. A thing that can sometimes go unnoticed if there is something else to handle the error.


So, unless the errors are expected (this way you know exactly the issue and can handle the exception accordinally), i don't see much reason to use it.
Try-Catch is used in some of the core scripts where things outside of the game could go wrong, and I have found it useful while debugging in my own development in conjunction with console.error().


What I'm surprised to not see is much reference to F8 and using console.log().
What I'm surprised to not see is much reference to F8 and using console.log().



I had seen this on one of the first tutorials about RMMV and it's incredible useful. So I have add a lot of console log outputs with different log levels (from full debug to errors only).

Original thread: https://forums.rpgmakerweb.com/threads/why-no-error-handling.58596/