ReadString exception freezes app?

BlitzMax Forums/BlitzMax Programming/ReadString exception freezes app?

Andres(Posted 2009) [#1]
					Try
						bytes = ReadString(requestedFile, sendPacketSize)
						sendString(bytes)
					Catch ex:Object
						Notify("Exception: " + ex.toString())
						Self.close()
						
						Return False
					End Try


why doesn't my program continue to run after exception is catched? it's a server code where server sends data to client.

i'm writing a new jpg from my webcam in every few seconds and the client/browser requests it too in every few seconds. And at some point it gives me an exception, but the server doesn't keep on running, just freezes.

I'm now catching the exception, but it doesn't seem to do any good. After the exception it just closes the connection, but that doesn't help either. :(

can some one please help, or anyone has any suggestions?


GW(Posted 2009) [#2]
Don't use exceptions! (unless you want to throw them yourself)
The list of what they don't catch could fill a book.
Manually check your variables and states instead.


Andres(Posted 2009) [#3]
I wouldn't use "try catch", but the error sayd unhandled exception, i don't even like exception. Id be glad to get rid of it, but if it's not possible to avoid it then i as well can use it.

The server is a HTTP server, it doesn't (atleast i haven't seen it yet) through exception with other files, but with just that jpg i am saving from webcam.

Can SavePixmapJPeg() write to a file that is already open for read? if it's possible then i might know why it happens.

I'm opening the jpg in the server for read and in every frame i send 1024 * 5 bytes of the file to browser, but if SavePixmapJPeg can write to file at the same time then the jpg's (as you know all jpg's with same pixel count don't weight the same) file size can change.
Could this be possible?

I read a little source about SavePixmapJPeg and it uses WriteStream. Haven't used it ever so i don't know what's possible with it.