views:

34

answers:

1

I am new to ruby and rails but seem to be getting the hang of it better than I expected...

So I have a few instance methods, within which calls to ruby gems are made. When one of them throws an error, how do I get that to gracefully pass back to the client? Either let it keep going if it can and display an error message, or die and give one.

Still getting my head wrapped around things. I know I should be testing and thats the next thing i'm doing... is thats what testings for? I mean, i'm going to be simulating various situations and seeing how the code reacts and then trying to get it to do so gracefully... but, i could use some guidance as to how.

I'd like it if, for example, I have 4 partials on a page, each a feed from a remote site. if a website goes down, i'd want just that partial to go down, and the rest to function.

So, i am a little unsure of how to accomplish this. or, is this a very DIY thing?

A: 

You need to wrap code that could throw an error in a begin-rescue-end. Check it out: http://ruby-doc.org/docs/ProgrammingRuby/html/tut_exceptions.html

Basically, tell ruby how to "rescue" those errors.

phaedryx