B4J Question how to catch AsyncStreams error ?

peacemaker

Expert
Licensed User
Longtime User
Hi, All and @Erel especially,

Question about the catching error from stream (here https://www.b4x.com/android/forum/threads/asyncstream-com-port-buffer.143231/), log is so:


Error does not stop the process, but it occured (when device is unplugged) ! I guess, in another thread.
AStream_Error occured only after whole buffer is empty.
And to work correctly - i need to catch it and stop the stream. But how to do it ?
 

peacemaker

Expert
Licensed User
Longtime User
handle the Error
This one is raised in B4J, but only all the system serial buffer is empty, 20-30 seconds processing is going on.
But is it possible to catch "java.lang.NegativeArraySizeException" error ?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
This one is raised in B4J, but only all the system serial buffer is empty, 20-30 seconds processing is going on.
But is it possible to catch "java.lang.NegativeArraySizeException" error ?
This error, which happens on a different thread, should be caught by AsyncStreams and lead to the Terminated or Error events being raised. Are you handling both events?
 
Last edited:
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
If internally in the lib to catch NegativeArraySizeException error and raise the _Error or _Terminated immediately - it will be correct, i think - as the port is immediately out.
But ... it will lead to incompatibility with old lib behaviour when this error did not crash the app. Maybe a new event to be added ?
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
BTW, never seen that _Terminated is raised independently.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…