Handling java errors within B4A?

positrom2

Active Member
Licensed User
Longtime User
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".
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
 

positrom2

Active Member
Licensed User
Longtime User
Thanks corwin42,
Put your problematic code which sometimes throws exceptions into a Try/Catch block.
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
Top