I am really confused in terms:
- Do not use exceptions as a control flow.
- Do not return nil / false as an exception
Let's say I have the following instance method:
class Logo
def process
begin
@logo_image = RmagickHelper.new(self.src)
rescue Magick::ImageMagickError
raise Exceptions::LogoUnprocessable, "ImageMagick can't process the URL"
end
end
end
So, in a more general method, I have the following:
def build_all_images
begin
@logo.process
rescue Exceptions::LogoUnprocessable
@logo.status = 'unprocessable'
return false
end
end
My question is:
Is it right to do this:
raise Exceptions::LogoUnprocessable, "ImageMagick can't process the URL"
Or should I just do
return false
source
share