division by 0 or null, modulo 0 or null ...

Post your questions and help other users.

Moderator: Martin

Post Reply
User avatar
Bushmills
Posts: 286
Joined: 23 Sep 2014 21:56

division by 0 or null, modulo 0 or null ...

Post by Bushmills » 02 Nov 2014 13:28

don't throw exceptions. I believe they ought to.
I haven't tested with square root of negative numbers, but assume the same to be the case.

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: division by 0 or null, modulo 0 or null ...

Post by Martin » 03 Nov 2014 20:32

a=1/0;
a=1/null;
a=1%0;
a=1%null;
throw exceptions for me.

User avatar
Bushmills
Posts: 286
Joined: 23 Sep 2014 21:56

Re: division by 0 or null, modulo 0 or null ...

Post by Bushmills » 05 Nov 2014 15:12

Very strange - for the flow posted in feature request putElement, I was specifically looking for a simple exception throwing instruction, to break out of an infinite loop (action VM or Virtual Machine) - so I tried several, starting with the most obvious ones, like division by zero. Within that trial and error session, I arrived at "not 0" which worked for me.
Meanwhile I have edited it to say "not good" for added syntactical icing. There is a possibility that I came across another problem, reported in eval with curly braces, which made me believe that these operations wouldn't throw exceptions - while in reality they were never executed.

User avatar
Bushmills
Posts: 286
Joined: 23 Sep 2014 21:56

Re: division by 0 or null, modulo 0 or null ...

Post by Bushmills » 08 Nov 2014 20:14

Another reason for not getting those exceptions may have been that it is possible to jam them.
Please refer to the accompanying flow, following these instructions:

after importing, execute it, no matter whether enabled or kept disabled.
Wait until the flow aborts because of execution limit.
Immediately execute the flow again, without enabling it. Watch its execution.

The scenario may be contrived, but the observation of not throwing the exception after second start may point to a real problem.

http://automagic4android.com/flow.php?i ... 72a610b1a7

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: division by 0 or null, modulo 0 or null ...

Post by Martin » 10 Nov 2014 16:17

Interesting observation! It's caused when the flow is executed manually and reaches the emergency stop count. The internal execution counter is not reset when you directly start the flow again without enabling the flow first so it will immediately halt execution on the first action but will miss to show the notification about the emergency stop. I think it should be save to reset the internal counter when a flow is executed manually. This should be fixed in the next build.

Post Reply