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: 
jbrave
Channel Surfer

Associative Array for error codes...

would be nice to be able to do something like this:

{500:"internal Server Error",501:"not implemented"}

just for example, so one could quickly build a table of codes to return value from.

Any suggestions, am I missing something here? I would hate to have to write a massive set of if/then's to do something like this.

- Joel
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
0 Kudos
3 REPLIES 3
renojim
Community Streaming Expert

Re: Associative Array for error codes...

You can always do this:
codes = {}
codes.AddReplace("500","internal Server Error")
codes.AddReplace("501","not implemented")
then
error = SomeFunction() ' returns an Integer
?codes[error.toStr()]

Another option would be to build your table with a leading character:
codes = {x500:"internal Server Error",x501:"not implemented"}
then use:
?codes["x"+error.toStr()]

-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.
0 Kudos
RokuMarkn
Visitor

Re: Associative Array for error codes...

Not sure if this is what you were asking, but see this post for a list of error codes. This will be provided as a public AA in a future release.

--Mark
0 Kudos
jbrave
Channel Surfer

Re: Associative Array for error codes...

Thanks, I was really looking for the method as opposed to the codes, I used http codes as the example, but this is for a completely different set of codes.

-Joel
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.