lucasgonze
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2011
03:23 PM
runtime error 18: Type Mismatch
The third line here sometimes causes a crash with "runtime error 18: Type Mismatch":
The rsp variable might contain a string or it might contain invalid. The string might not be valid xml, sure, but I don't think that the error in that case would be a type mismatch. The value might be invalid, but in that case the fatal_connection_error() call will prevent processing reaching the line with the type mismatch.
So it must be xml.Parse that is the mismatch. xml must contain a thing that is not an roXMLElement. Most likely it's invalid.
That implies that Brightscript apps need to always check for allocation errors in CreateObject(). We can do that, and I guess we will, but all we'll do with the failure is to shut down with a prettier error screen than a crash will give you.
Ideas welcome.
if( rsp = invalid ) fatal_connection_error()
xml = CreateObject("roXMLElement")
if not xml.Parse(rsp) then
The rsp variable might contain a string or it might contain invalid. The string might not be valid xml, sure, but I don't think that the error in that case would be a type mismatch. The value might be invalid, but in that case the fatal_connection_error() call will prevent processing reaching the line with the type mismatch.
So it must be xml.Parse that is the mismatch. xml must contain a thing that is not an roXMLElement. Most likely it's invalid.
That implies that Brightscript apps need to always check for allocation errors in CreateObject(). We can do that, and I guess we will, but all we'll do with the failure is to shut down with a prettier error screen than a crash will give you.
Ideas welcome.
6 REPLIES 6
renojim
Community Streaming Expert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2011
04:08 PM
Re: runtime error 18: Type Mismatch
How exactly does fatal_connection_error() prevent the following statements from executing? Does it never return? Shouldn't there be an 'else' in there someplace?
-JT
-JT
Roku Community Streaming Expert
Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.
I am not a Roku employee.
Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.
I am not a Roku employee.

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2011
04:10 PM
Re: runtime error 18: Type Mismatch
If the xml object weren't valid, you wouldn't get a Type Mismatch. The problem is almost definitely the rsp variable. What is the code that sets that?
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
kbenson
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2011
04:12 PM
Re: runtime error 18: Type Mismatch
somehow, rsp is invalid. xml was correctly assigned, otherwise you would get an error about trying to access an invalid method or attribute of a brightscript object (I forget the exact wording), since there would be no parse method if the object wasn't assigned correctly. I suggest testing that the "fatal_connection_error()" function is actually stopping the channel.
-- GandK Labs
Check out Reversi! in the channel store!
Check out Reversi! in the channel store!
lucasgonze
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2011
04:18 PM
Re: runtime error 18: Type Mismatch
fatal_connection_error() is supposed to exit. It's gives a screen that says you have crashed, sorry, etc.
I wonder if there's a way out of it that we're not aware of? Maybe the back key in that screen takes the user back to the calling routine, and then control flows down to the xml.parse() call.
TheEndless, the code that sets it either returns invalid or returns the value of a getString() on an roUrlTransfer object. So if getString can return something which would cause the xml parser to throw a type mismatch, that could also be the cause.
I wonder if there's a way out of it that we're not aware of? Maybe the back key in that screen takes the user back to the calling routine, and then control flows down to the xml.parse() call.
TheEndless, the code that sets it either returns invalid or returns the value of a getString() on an roUrlTransfer object. So if getString can return something which would cause the xml parser to throw a type mismatch, that could also be the cause.

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2011
04:55 PM
Re: runtime error 18: Type Mismatch
Have you tried checking the Type of rsp when it crashes in the debugger?
?Type(rsp)
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
lucasgonze
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2011
05:11 PM
Re: runtime error 18: Type Mismatch
"TheEndless" wrote:
Have you tried checking the Type of rsp when it crashes in the debugger??Type(rsp)
All I know is that the system crash logs are seeing the error thrown. I don't even know about the overall system flow to get there.
My plan of attack to see about forcing rsp to invalid, then going into the fatal error screen and looking for a way to get back to the calling routine.