Question

For example, I want to rescue from a Net::HTTP::Persistent::Error, however it has many types:

Net::HTTP::Persistent::Error: too many connection resets (due to end of file reached - EOFError)
Net::HTTP::Persistent::Error: too many connection resets (due to Timeout::Error - Timeout::Error)
Net::HTTP::Persistent::Error: connection refused: domain:443

For each type I want to do something else, how would that be done?

Was it helpful?

Solution

They seem to belong to the same error class, so you cannot distinguish them by the error class. Try to inspect each error and see if it has some instance variables that hold the details of the error, based on which you can differentiate the types. If there is no such instance variables to the error, perhaps the best you can do is to parse the error messages to distinguish them.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top