[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Ovirt-devel] [patch] Even Better Exceptions For ruby-libvirt bindings



On Tue, Apr 01, 2008 at 05:02:51PM -0400, Chris Lalancette wrote:
> Chris Lalancette wrote:
> > Mohammed Morsi wrote:
> >> Updated and attached. Good news is everything compiles fine and 
> >> everything seems to work. Due to request, I did not add the libvirt 
> >> exception structure to the ruby-libvirt exception object, rather the 
> >> message field is copied over. For the next revision the code, domain, 
> >> level, other message fields, and anything else anyone needs will also be 
> >> included. Enjoy!
> 
> Actually, besides my previous points, let me ask a question.  Given the
> following code snippet:
> 
> #!/usr/bin/ruby
> 
> require 'libvirt'
> 
> conn = Libvirt::open
> 
> conn = Libvirt::open('foo')
> 
> conn = Libvirt::open('qemu+tcp://foo.perf.redhat.com/system')
> 
> Currently, these three open calls snippets all fail with ArgumentError.  As I
> understand your new code, these will all now end up with "e_ConnectionError",
> with some string set showing what the error was.  However, that's still not
> fine-grained enough; in the first case, it's a programming error, so I want to
> strack trace the whole program.  In the second case, it's a user error (entering
> the wrong connection string in the database), so I want to fail gracefully with
> the error message.  In the third case, the user did everything right, but the
> network or the box wasn't up, so I want to fail gracefully with the error message.

No, all three of those are the same & should be handled the same way. The
first should call virConnectOpen(NULL) letting libvirt probe the hypervisor
and is *not* a programming error.

All 3 should fail gracefully with the error message libvirt provides in the
virErrorPtr object.

Dan.
-- 
|: Red Hat, Engineering, Boston   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]