From: Lyle Johnson Date: 2008-04-03T06:18:20+09:00 Subject: Re: ruby constructor return value? On Wed, Apr 2, 2008 at 4:08 PM, Brendan Stennett wrote: > How do I alert an error if it occurs in an object's constructor? Raise an exception. class Zip def initialize(zipcode) o = Zipcode.find_by_zipcode(zipcode) if o.length == 0 raise ArgumentError, "no zip code specified" else @zipcode = zipcode end end end begin o = Zip.new('00000') rescue ArgumentError # deal with the error here end Hope this helps, Lyle