deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Koper, Dies" <di...@fast.au.fujitsu.com>
Subject RE: how to better log errors during development
Date Fri, 13 Apr 2012 12:43:38 GMT
Hi Michal,

It looks really useful!
Is it not possible to move the 'safely' invocations to the invoking
classes so that all drivers' methods would automatically be in safely
blocks without needing to explicitly write the block in every method?
Or are there cases where one would want to put code outside such a
block?

I noticed some drivers still raise exception classes, or use a
combination of both (see e.g. condor_driver's new_client method).
Why is that? When would I want to use safely raise a text string and
when a class from the Deltacloud::ExceptionHandler?

Cheers,
Dies Koper


> -----Original Message-----
> From: Michal Fojtik [mailto:mfojtik@redhat.com]
> Sent: Friday, 13 April 2012 12:17 AM
> To: dev@deltacloud.apache.org
> Subject: Re: how to better log errors during development
> 
> Hi Dies,
> 
> We're using a small DSL for capturing and dealing with different kind
> of errors that came from backend provider. For that we have the
'safely',
> block that you can see in many existing drivers.
> 
> A sample of using this:
> 
> def instances(credentials, opts={})
>   client = new_client(...)
>   safely do
>     # do something that is can throw exception
>   end
> end
> 
> Then somewhere on bottom of the driver file, you can see this:
> 
> exceptions do
> 
>   on /(AuthFailure|InvalidKey)/ do
>     status 401 # HTTP_AUTH
>   end
> 
>   on /Error/ do
>     status 502 # Provider error
>   end
> 
> end
> 
> Then all exceptions are captured by this system and delivered to
clients
> in XML or JSON format with full backtrace.
> 
>  -- Michal
> 
> Michal Fojtik
> http://deltacloud.org
> mfojtik@redhat.com
> 
> 
> 
> On Apr 12, 2012, at 3:56 AM, Koper, Dies wrote:
> 
> > Hi,
> >
> > While developing the FGCP driver, I often introduce bugs where I
invoke
> > [] on a nil object.
> > When using the DC GUI, this causes the following backtrace:
> >
> > NoMethodError - undefined method `code' for
> #<NameError:0x7fe779972da0>:
> >
> >
>
/mnt/hgfs/deltacloud/server/lib/deltacloud/helpers/application_helper.rb
> > :69:in `filter_all'
> > 	/mnt/hgfs/deltacloud/server/lib/deltacloud/server.rb:676
> >
> > The line is:
> >
> >        report_error(@exception.code)
> >
> > If I add a 'puts @exception.backtrace' in front of it it at least
logs
> > the backtrace to the bug in my bug.
> >
> > Can we introduce such a chance here, and if we do, what kind of
change
> > would fit best?
> >
> > Thanks,
> > Dies Koper
> >
> 



Mime
View raw message