List Info

Thread: Question about error handling in *Store




Question about error handling in *Store
user name
2006-04-26 20:18:12
On 4/26/06, gabriele renzi <surrender_ityahoo.it> wrote:
> Hi people,
>
> I notice that all the Og::Store subclasses are defined
in files with an
> header similar to
>
> begin
>    require 'sqlite'
> rescue Object => ex
>    Logger.error 'Ruby-Sqlite bindings are not
installed!'
>    Logger.error ex
> end
>

$ grep -R 'rescue Object' nitro/* glue/* og/* gen/*
nitro/lib/glue/sweeper.rb:    rescue Object
nitro/lib/nitro/compiler/script.rb:    rescue Object
nitro/lib/nitro/helper/debug.rb:    rescue Object
nitro/lib/nitro/adapter/mongrel.rb:    rescue Object =>
ex
nitro/lib/nitro/adapter/scgi.rb:            rescue Object
nitro/lib/nitro/adapter/scgi.rb:                rescue
Object
nitro/lib/nitro/adapter/webrick.rb:              rescue
Object => ex
nitro/lib/nitro/adapter/webrick.rb:    rescue Object =>
ex
nitro/lib/nitro/caching/output.rb:      rescue Object =>
ex
nitro/lib/nitro/helper.rb:            rescue Object
nitro/proto/script/scgi_service:        rescue Object =>
nitro_error
nitro/proto/script/scgi_ctl:    rescue Object
nitro/test/nitro/tc_session.rb:  rescue Object #
Errno::EBADF => e
glue/lib/glue/configuration.rb:        rescue Object
glue/lib/glue/mailer/outgoing.rb:          rescue Object
=> e
og/lib/og/store/sqlite2.rb:rescue Object => ex
og/lib/og/store/sqlite2.rb:    rescue Object
og/lib/og/store/sqlite2.rb:    rescue Object => ex
og/lib/og/store/sqlite2.rb:        rescue Object => ex
og/lib/og/store/alpha/sqlserver.rb:rescue Object => ex
og/lib/og/store/kirby.rb:rescue Object => ex
og/lib/og/store/kirby.rb:      rescue Object
og/lib/og/store/sqlite.rb:rescue Object => ex
og/lib/og/store/sqlite.rb:    rescue Object
og/lib/og/store/sqlite.rb:        rescue Object => ex
og/lib/og/store/mysql.rb:rescue Object => ex
og/lib/og/store/mysql.rb:  rescue Object => ex
og/lib/og/store/psql.rb:rescue Object => ex
og/test/og/tc_cacheable.rb:rescue Object

It's a general tendency of George's. I can confirm this as
my original
capture of Errno::EBADF here was changed.

nitro/test/nitro/tc_session.rb:  rescue Object #
Errno::EBADF => e

> There are two things I found strange in this, first, it
seems excessive
> to hide all possible exceptions by rescueing Object, I
think that
> LoadError would be a better fit; second, I 'm not sure
I undesrtand why
> the problem is just logged instead of letting the
application crash,
> because in most cases there will be a crash whenever
something is done
> that is store related,  by referencing a a nil object.
>

Personally, I tend to agree that exception handling should
be as
specific as possible. Differing philosophies, I suppose. But
you make
a very good point on the stores I think.

> It seem to me that this is a bad thing and that a
crash-early approach
> would be better and allow faster diagnostics, but maybe
there is
> something I have overlooked.

Anyone have any objections to changing this? Seems to be a
bug to me.

> Someone who would like to still use the application
withouth having a
> real reference to a Store could just create an empty
foo.rb in src/ and
> go on anyway.
>

That is equivalent to what we're currently doing, isn't
it. 

Bryan

--
"Never tell people how to do things. Tell them what to
do and they
will surprise you with their ingenuity." —General
George S. Patton

_______________________________________________
Nitro-general mailing list
Nitro-generalrubyforge.org
h
ttp://rubyforge.org/mailman/listinfo/nitro-general
Question about error handling in *Store
user name
2006-04-27 07:18:29
Bryan Soto ha scritto:

>>Someone who would like to still use the application
withouth having a
>>real reference to a Store could just create an empty
foo.rb in src/ and
>>go on anyway.
>>
> 
> 
> That is equivalent to what we're currently doing,
isn't it. 

well, yes, but it becomes an explicit choice of the
developer and not an 
hidden thing.

George could you please comment on this and on the general
"large 
rescue" thing?

thanks bryan for the quick answers anyway 

_______________________________________________
Nitro-general mailing list
Nitro-generalrubyforge.org
h
ttp://rubyforge.org/mailman/listinfo/nitro-general
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )