Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
manishDev
Visitor

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 4
georgejecook
Streaming Star

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://georgejecook.github.io/
https://linkedin.com/in/georgejecook/
Roku developers slack group (https://join.slack.com/t/rokudevelopers/shared_invite/zt-4vw7rg6v-NH46oY7hTktpRIBM_zGvwA) : georgejecook

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

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
Streaming Star

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://georgejecook.github.io/
https://linkedin.com/in/georgejecook/
Roku developers slack group (https://join.slack.com/t/rokudevelopers/shared_invite/zt-4vw7rg6v-NH46oY7hTktpRIBM_zGvwA) : georgejecook

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

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