Debugging in Companion - Getting caller function name

Hello All,
In my app I try to catch everything that can go wrong using Screen1.ErrorOccured(). Now I'm getting an annoying error when I start my application and amongst my ~10k blocks I'm not able to find the root of it. The output I'm getting is " Division 3200 Trying to divide 0 by 0. The result might not be valid".

I failed to identify where this bug could be. Function name is "Division" - well, from the error message I figured but how to proceed? I guess the ID xxxx.Screen1@faf7113 also belongs to the Division() function.

Seeing the block that caused the isse would solve my problem but I see no option to see that. Could someone please guide me how to debug? Actually, what concerns me is not the actual bug but the fact how little possibilities I'm having when I need to debug something using Companion. I'd be happy if I could learn how to do that.

At the moment I'd like to keep the application to myself and prefer not to upload it entirely for now. If there is no good method to follow, I can of course disable large blocks and see when the error message goes away but my code is scattered to a tons of functions so I'd keep this as a last resort.

Thank you, I'm looking forward to your precious advice.

You are dividing something by 0 somewhere in your program. Use KevinKun's AI2Helper (browser) extension to find the blocks responsible for the error (search for "/"):

Wow, I didn't know about that extension, thank you for the tip! But this only helps me finding the function by name. What I need is to find the caller function of an error message that I believe won't work at the browser's side. It's rather something that the Companion could help me with (e.g. as an addition to the error message that has less meaning for me, it could give me the whole chain of calls). The best would be of course if the browser would automatically jump to the block that ultimately caused the problem. Like in this case, when the divider is zero somewhere in my big program, it could've jump to the block that actually does the division.

You can. :slightly_smiling_face:

The error is in your BIG PROGRAM (the blocks of which you do not share) at a point where you divide. Certainly you can find that. Once you find the blocks you use to divide, use the available tools Live Development, Testing and Debugging to help you find your blocks that cause the problem.

1 Like

OK Guys, you are very smart programmers and I'm a programmer, too so no need to pretend that you don't understand me. If you take a look to any development software, it is able to raise a sane error message and point to the location of the problem. Of course I can spend 10-15 minutes to find it amongs ~12k blocks but I just don't want to spend the time because I already spent a lot of hours developing my app.

What you are saying here is that App Inventor cannot do such a simple thing that showing where the programmer made a mistake so the programmer have to find it manually. Since I can use App Inventor for free, I have no right to complain but in my opinion the MIT Guys should consider adding this feature. This would help a lot to the users to do some serious work (e.g. more than playing with 100 blocks).

1 Like