Forum Discussion

manishDev's avatar
manishDev
Visitor
8 years ago

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.

4 Replies

  • "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.
  • 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.
  • "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.