How do I make an error show the entire line of code?

Dupletor

Member
I noticed a somewhat inconsitent behavior for gamemaker during fatal error screens.
Sometimes it shows the entire line of code, sometimes it only shows the problematic variables. How do I make it always show the entire line?

Take for example this error:


#
FATAL ERROR in action number 1 of Step Event0 for object obj_player:


Variable obj_player.layer_bullet(100002, -2147483648) not set before reading it. at gml_Object_obj_player_Step_0 (line 30) - instance_create_layer(x, y, layer_bullet, obj_bullet);

#

If I execute the game from inside gamemaker, the error appears in its entirety.
However, if I create an .exe and run it independently, this is the error that appears:



#
FATAL ERROR in action number 1 of Step Event0 for object obj_player:


Variable obj_player.layer_bullet(100002, -2147483648) not set before reading it. at gml_Object_obj_player_Step_0 (line 30) -

#

While a couple of months ago, it would show the entire error.
Is there a way for me to force the error screen to show the line of code?
 
Last edited:

FoxyOfJungle

Kazan Games
Is there a way for me to force the error screen to show the line of code?
No, however I've never had any problems with this, I've always found it simple to spot these errors. Your code in question, I believe you want to do this:

instance_create_layer(x, y, "layer_bullet", obj_bullet);


Variable obj_player.layer_bullet(100002, -2147483648) not set before reading it. at gml_Object_obj_player_Step_0 (line 30) -
The line, the object, the event and the variable is already shown, so you don't even need to know the rest.
 

Dupletor

Member
I know how to read the error and find it or fix it, that's not the point. This is just a random error I copied from a basic reddit post to replicate the problem.
I just need the error to appear completely to the user, and not to some users.
 

Nidoking

Member
I just need the error to appear completely to the user, and not to some users.
Why? Literally, what possible reason could there be to want to show your code to users? It's all meaningless information to the majority of users, it's bad security in terms of the users who can understand the error, and in most cases, the goal should be to show NO errors to any users because errors are pretty much always unintended. Why don't you just post all of your code in a Google doc and put the link in the game so your users can look up the code for themselves?
 

Vusur

Member
I guess you want tester send you the crashreport and have more information? If this is the case and the standard crashreport is not enough, you can write your own error handling.
Try-Catch blocks, that need special attention when throwing an error. Fill catched error with additional information.
Throw the custom error, so that the game still crashes (I'm against recovery strategies in GMS. But that's probably because of usual errors I run into. Won't deny that there might be a few stratagies, i.e. asynchron events or file handling)
Handle the custom error and maybe even write into a custom crashlog. Tell your tester to send you the crashlog. Is imho better then getting a screenshot or they copy/paste the error window.

Would I do that? No. So far I didn't found a use-case for that. If an error appears, it's just me being dump. The normal crash message is enough.
 
Literally, what possible reason could there be to want to show your code to users?
So they can show it to you, and then you can fix it? Compiled errors are a bit useless. All they really do is show how often a specific error occurs.

the goal should be to show NO errors to any users because errors are pretty much always unintended.
Yes, and the best way to do that is to fix the problem when you find it but finding a bug from a user submitted error message is quite a difficult task. You will need them to say what they were doing (and most often they won't remember or give you the wrong answer).
 
So they can show it to you, and then you can fix it? Compiled errors are a bit useless. All they really do is show how often a specific error occurs.
While this is true, I think the weirdness is coming from the fact that both errors the OP is talking about literally say exactly where the error is: the variable layer_bullet in the player object at line 30. Why they would need to see the exact code quoted back verbatim is strange when they simply need to read either error message to know what and where the error is.
 

sylvain_l

Member
While this is true, I think the weirdness is coming from the fact that both errors the OP is talking about literally say exactly where the error is: the variable layer_bullet in the player object at line 30. Why they would need to see the exact code quoted back verbatim is strange when they simply need to read either error message to know what and where the error is.
I assume because I have edited my code since the build, and the line number doesn't match any more.
( in theory I could keep a branch corresponding to each build in git, but then I would require to ensure that the user give me the right build version he is using)
 

Vusur

Member
I assume because I have edited my code since the build, and the line number doesn't match any more.
( in theory I could keep a branch corresponding to each build in git, but then I would require to ensure that the user give me the right build version he is using)
I see what you mean, but this is a problem with version control. You should have 2-3 branches. It will make your life easier. Trust me, that is my painful experience.
(1) is for your stable build, i.e. that matches for steam version. Don't touch this!
(2) is what you give your tester team (if there exists one) or what you use as a beta. Don't touch this.
(3) is your dev branch, where you and your team actual work on and where you do new features

Checking a problem from (1) and (2) against your current work is never a good idea. Who knows what new side effects are created due the new features and/or if you already have fixed it by accident. The line of code won't really help in this case, unless you get the whole event code. Identifying the problem should always happen in the version they came from. Then you decide, if it needs attention in your current work -> Ticket or if you might have fixed it already.
Or lets make it more serious. You get reports about a really nasty bug with data loss. You are deep into coding new features. How do you hotfix this? Deleting your progress, so you can fix it or let the user wait, till your dev version is stable enough before pushing out the hotfix?

I even use more branches. (1) is divided into stable and hotfix. (2) also divided into beta and hotfix. (3) divided into main dev, where new and finished features are in + branches for current develeopments of independent features (one or two. Starting to many new features is a bad idea in my case).
Thankfully git makes it really easy. Merging stuff is usually not a problem.

In the end it's the other way around. You don't ensure, that the user gives you the right build version. You ensure to give the user the appropriate build version. It's easier with games than other software, where updates are optional. If everything goes downhill, then you customize the error handler, so that it throws the current build version with the error stack. And while at it, let it write a crashfile, instead having a crash report in a window.

Because how does a usual user behave: Game crashes. User reads the error. Closes the window. Goes to your forum and yells at you. Now you ask what exactly happens, he tells you what he think he did and now you can play the guess game. Asking for the error code won't succeed most of the time, because the user closed the window. If the error is not that easy to reproduced, you are in for a ride. On the other hand, Crash -> proper custom logfile + crash message, you just ask him to copy the contents from a file in folder XY.

Now if I think about it, does GMS write a crashfile for a finished build or do we have to do it ourself?
 

Dupletor

Member
This went waaay past the point.

Again, the code I brought is utterly irrelevant. It is not mine, it's just a representation of the matter.
I just wanted to be able to throw my own error, which Vusur brought, so thanks.

And after IWBTG it really shouldn't be of such a surprise that people would want to be able to throw errors at will, I just don't want to spoil anything. :p

I can just throw a fake like of code as error for the same effect.
 
Top