You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by "Koper, Dies" <di...@fast.au.fujitsu.com> on 2012/04/12 03:56:01 UTC

how to better log errors during development

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


RE: how to better log errors during development

Posted by "Koper, Dies" <di...@fast.au.fujitsu.com>.
Hi Michal,

I've added safely's to all my methods dealing with the backend and
noticed that for some operations the GUI shows the error message with
stacktrace but with others it does not. Why the inconsistency?

I get a proper error page with all the instances, addresses,
hardware_profiles, loadbalancers, etc. operations.
No error page with:
- create_address (Create new address seems to do nothing)
- create_loadbalancer (After pressing 'create', a message "Error Loading
Page" is displayed for half a second)
- create_storage_volume (After pressing 'create', a message "Error
Loading Page" is displayed for half a second)
- create_storage_snapshot (After pressing 'create', a message "Error
Loading Page" is displayed for half a second)

Regards,
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
> >
> 



RE: how to better log errors during development

Posted by "Koper, Dies" <di...@fast.au.fujitsu.com>.
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
> >
> 



Re: how to better log errors during development

Posted by Michal Fojtik <mf...@redhat.com>.
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
>