RTC Forums
May 16, 2024, 04:18:43 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: Exception didn't raise in OnResultReturn.  (Read 4013 times)
Theprasit
RTC License++
*****
Posts: 42


« on: January 25, 2013, 12:06:46 PM »

I notice that a code I wrote inside OnResultReturn is not fire an exception when "Run without Dedug". Program is continue to run without signal any error. But using "Run with Debug" will raise exception normally.

I used the code from "FishFactClient" demo with rtcDB.

Do I made some mistake?

Thank You.

P.S. My code is a bit long, if you need, I will post here.
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #1 on: January 25, 2013, 12:55:31 PM »

It is incorrect to say that the exception didn't raise. The Exception will be raised, but since there is no other user code around your own code block which could handle the exception after the event completed, the exception will have to be handled by the RTC component triggering the event.

Because RTC events are often executed from background threads, there is also no point in re-raising the exception, since it would only result in the connection thread to terminate and the connection to close. And that's definitely NOT what you would to happen, so the RTC components can only assume that the user exception was not important and can safely be ignored.

In other words ... if there is a possibility of an exception to be raised inside your own code called from a RTC event, I strongly suggest using try/except blocks around your code and handling all expected exceptions. Any exception that isn't handled will be captured by the RTC code triggering the event and ignored, simply because there is no way to forward all the relevant Exception information to some other user code. Even if there was a new event "OnUserException" on each RTC component added, it would not help you much at runtime without knowing where the exception happened. And this is why exceptions should be handled where they are being raised - inside your own code blocks.

Best Regards,
Danijel Tkalcec
Logged
Theprasit
RTC License++
*****
Posts: 42


« Reply #2 on: January 25, 2013, 01:38:22 PM »

Normally, I used "madexception" to handle un-handle exception. Do this also in this situation as well?

The error that trigger the exception is DataSet.FieldByName('bla').. . where "bla" is not in my table (typing mistake). This should be trigger an exception in runtime.

Did you mean that I have to handle all of exception inside RTC event?

Thank You
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #3 on: January 25, 2013, 01:57:00 PM »

I mean that you have to handle exceptions raised inside you own code blocks, including exceptions raised by any code you are calling from inside your own code block, unless you don't care about the exception, in which case it will be handled by the RTC component and handled silently.

Best Regards,
Danijel Tkalcec
Logged
Theprasit
RTC License++
*****
Posts: 42


« Reply #4 on: January 30, 2013, 04:23:10 AM »

Thank you for your advice. I understood and managed to handle these kind of exceptions ready.

Regards,
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.025 seconds with 17 queries.