Why no error handling?

Purzelkater

cat as cat can
Veteran
Joined
Feb 20, 2016
Messages
86
Reaction score
69
First Language
German
Primarily Uses
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
 

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
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.
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
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?
 
Last edited by a moderator:

Purzelkater

cat as cat can
Veteran
Joined
Feb 20, 2016
Messages
86
Reaction score
69
First Language
German
Primarily Uses
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.
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
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.
 

Victor Sant

Veteran
Veteran
Joined
Mar 17, 2012
Messages
1,694
Reaction score
1,452
First Language
Portuguese
Primarily Uses
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.
 

Reedo

Coder
Veteran
Joined
Sep 17, 2013
Messages
71
Reaction score
38
First Language
English
Primarily Uses
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().
 

Purzelkater

cat as cat can
Veteran
Joined
Feb 20, 2016
Messages
86
Reaction score
69
First Language
German
Primarily Uses
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).
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

People3_5 and People3_8 added!

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.

Forum statistics

Threads
105,868
Messages
1,017,081
Members
137,582
Latest member
Spartacraft
Top