P positrom2 Active Member Licensed User Longtime User Jul 3, 2012 #1 Is it possible to handle java errors (stopping a program) within B4A? I am asking since I am still struggling with transfering data between µC and B4A. Textreader occasionally throws the error and stopps the program execution: An error has occurred in sub:main_mainloop (java line: 818) "java.lang.numberFormatException:Invalid double:"2@?262". Click to expand... For a certain combination of µC code and B4A code the interaction runs smoothly quite long. However when changing apparently subtle things on either side this error occurs (at varying java lines). Since I could not find out the real problem I would like to intercept the java error. I was not able to check the input from textreader for valid characters in order to prevent the java error to occur. Of course, that would be the best, any suggestion on that? (Also with asyncstreams I am having no more (even less) luck). Thanks, positrom2
Is it possible to handle java errors (stopping a program) within B4A? I am asking since I am still struggling with transfering data between µC and B4A. Textreader occasionally throws the error and stopps the program execution: An error has occurred in sub:main_mainloop (java line: 818) "java.lang.numberFormatException:Invalid double:"2@?262". Click to expand... For a certain combination of µC code and B4A code the interaction runs smoothly quite long. However when changing apparently subtle things on either side this error occurs (at varying java lines). Since I could not find out the real problem I would like to intercept the java error. I was not able to check the input from textreader for valid characters in order to prevent the java error to occur. Of course, that would be the best, any suggestion on that? (Also with asyncstreams I am having no more (even less) luck). Thanks, positrom2
corwin42 Expert Licensed User Longtime User Jul 3, 2012 #2 Put your problematic code which sometimes throws exceptions into a Try/Catch block. Upvote 0
P positrom2 Active Member Licensed User Longtime User Jul 3, 2012 #3 Thanks corwin42, Put your problematic code which sometimes throws exceptions into a Try/Catch block. Click to expand... When I do so it sometimes works but sometimes the app hangs completely not showing a message I had inserted into the "catch" routine that the java exception had occured. So I guess that there are some more severe error conditions that are not trapped by "try". I think it must be related to textreader getting upset by some characters. Is there any further suggestion? Thanks, positrom2 Upvote 0
Thanks corwin42, Put your problematic code which sometimes throws exceptions into a Try/Catch block. Click to expand... When I do so it sometimes works but sometimes the app hangs completely not showing a message I had inserted into the "catch" routine that the java exception had occured. So I guess that there are some more severe error conditions that are not trapped by "try". I think it must be related to textreader getting upset by some characters. Is there any further suggestion? Thanks, positrom2
Erel B4X founder Staff member Licensed User Longtime User Jul 3, 2012 #4 It is hard to say without seeing your code. How are you connecting to this device? Are you using AsyncStreams? Upvote 0
It is hard to say without seeing your code. How are you connecting to this device? Are you using AsyncStreams?