RTC Forums
November 24, 2024, 04:45:02 PM
Welcome,
Guest
. Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Home
Help
Login
Register
RTC Forums
>
Subscription
>
Support
>
Exception didn't raise in OnResultReturn.
Pages: [
1
]
« previous
next »
Print
Author
Topic: Exception didn't raise in OnResultReturn. (Read 5212 times)
Theprasit
RTC License++
Posts: 42
Exception didn't raise in OnResultReturn.
«
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
Re: Exception didn't raise in OnResultReturn.
«
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
Re: Exception didn't raise in OnResultReturn.
«
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
Re: Exception didn't raise in OnResultReturn.
«
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
Re: Exception didn't raise in OnResultReturn.
«
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
« previous
next »
Jump to:
Please select a destination:
-----------------------------
Dashboard
-----------------------------
=> General
=> 3rd-Party
=> Quick Start
-----------------------------
Subscription
-----------------------------
=> Support
Loading...