[Ruby] Catching an error when using class methods (Ryan Davis)
Ofer Matan
ofer at stanfordalumni.org
Thu Jul 19 12:50:40 PDT 2007
Ryan/Evan
The reason I want to do this is similar to the 2003 post I have a open
webservices request object from another library that I am caching and
reusing each in multiple methods:
request_object.CallTheWebserviceINeed
The cached object goes stale and raises an error - so I need to
reinitialize. I'd like to avoid writing again and again
begin
request_object.CallTheWebserviceINeed
rescue ErrorFromStale
<reinitialize request_object>
Retry
end
currently I have something like
def request_object
@request_obj ||= Iniatilize_and_return_request_object
End
I am trying to avoid removing the '||' and reinitializing every time and was
hoping to catch the 'stale' error and only reinitialize then.
Thoughts ?
More information about the Ruby
mailing list