Russell Fulton wrote:
> Hi,
>    I'm new to Ruby and still trying to figure out how best to do things 
> "the Ruby way".  The particular problem I am looking at now is the 
> initialize method of a class I am writing. Several things can go wrong 
> in calls to new for this class ranging from the caller specifying 
> incompatible parameters to database calls failing.
> 
> What is the perferred method of handling such errors? Simply raising 
> exceptions and returning nil?
> 
> Cheers, Russell
> 


You don't really have any choice. The return value from 'new' is an 
instance of the class, never nil. (Okay, some clever Rubyists could 
think of a way to make it nil, but no user of your class should ever be 
asked to handle that case.) If your initialize method can fail, it 
should raise an exception.