Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
manishDev
Level 7

catching runtime error

Any idea how one can catch runtime errors? I want to show a message to the user when any unexpected error occurs. This can be my way of error handling. I can even take the control back a couple of steps to redo whatever function was trying to.
0 Kudos
4 Replies
georgejecook
Level 7

Re: catching runtime error

use Eval to run the code, and check the result. I do this on some high risk code. Used occasionally and with caution, it can be handy. Other than that, use rodash, or similar library for getting chained objects e.g. a.b.c.value

https://forums.roku.com/viewtopic.php?f ... hilit=eval
https://github.com/Tubitv/rodash
George Cook
https://linkedin.com/in/georgejecook/
Roku developers slack group (http://tiny.cc/nrdf0y) : georgejecook

Contact me on roku developer slack group, or via pm to discuss consultancy/work opportunities/rooibos unit testing framework
0 Kudos
manishDev
Level 7

Re: catching runtime error

"georgejecook" wrote:
use Eval to run the code, and check the result. I do this on some high risk code. Used occasionally and with caution, it can be handy. Other than that, use rodash, or similar library for getting chained objects e.g. a.b.c.value

https://forums.roku.com/viewtopic.php?f ... hilit=eval
https://github.com/Tubitv/rodash

Thanks George. I am thinking of using Eval to do all my risky operations. Sounds like a reasonable approach. I avoid using chained values. I usually get my data bound to interfaces and have listeners on them to catch them into a local data. That way with a single rendezvous I can propagate variable repo to all files with minimum access to global node. Rodash library looks great. I will dive deeper and have a look at it.
0 Kudos
georgejecook
Level 7

Re: catching runtime error

glad it worked out. Yeah, I'm not fan of chained access - I have a pattern whereby I do all that in my takss; but even then, I can never be sure I got the json right from the server, so I use rodash.get() to avoid crashes in those circumstances. don't over use/abuse eval!! There are smarter people here than me, who can tell you why.
George Cook
https://linkedin.com/in/georgejecook/
Roku developers slack group (http://tiny.cc/nrdf0y) : georgejecook

Contact me on roku developer slack group, or via pm to discuss consultancy/work opportunities/rooibos unit testing framework
0 Kudos
manishDev
Level 7

Re: catching runtime error

"georgejecook" wrote:
glad it worked out. Yeah, I'm not fan of chained access - I have a pattern whereby I do all that in my takss; but even then, I can never be sure I got the json right from the server, so I use rodash.get() to avoid crashes in those circumstances. don't over use/abuse eval!! There are smarter people here than me, who can tell you why.

That's right. I have seen some other posts where devs have mentioned it. Somehow I feel it was easy to use in the SDK1. But I don't know any better. I never worked on SDK1.
0 Kudos