[Libvir] new ruby error handling

I have a dumb question about new error handling. What is the rationale for using 'libvirt_message' instead of 'message' in new Libvirt Ruby error classes? Here is an example of code I am writing: rescue SystemCallError process($!.message) ... rescue Libvirt::Error process($!.libvirt_message) ... instead of, shorter: rescue Libvirt::Error, SystemCallError process($!.message) ... In reality, my rescue classes are bit longer, so the code gets hairy. Wouldn't it be better to use standard 'message' attribute instead? Sincerely, Vadim -- "La perfection est atteinte non quand il ne reste rien a ajouter, mais quand il ne reste rien a enlever." (Antoine de Saint-Exupery)

On Thu, 2008-04-10 at 23:28 -0700, Vadim Zaliva wrote:
I have a dumb question about new error handling. What is the rationale for using 'libvirt_message' instead of 'message' in new Libvirt Ruby error classes?
The 'message' in the exception is set, too, usually to the name of the libvirt function that returned the error. libvirt_message stores additional error details from virError, which is not always available. That's how it works at the moment, but I am open to suggestions to change that. David

On Apr 11, 2008, at 10:15, David Lutterkort wrote:
The 'message' in the exception is set, too, usually to the name of the libvirt function that returned the error. libvirt_message stores additional error details from virError, which is not always available.
That's how it works at the moment, but I am open to suggestions to change that.
I guess my main complaint is that in some cases message is not a coherent English phrase, something I can show to users. So I would prefer to have "Error during call to XXX" instead of just "XXX". Vadim -- "La perfection est atteinte non quand il ne reste rien a ajouter, mais quand il ne reste rien a enlever." (Antoine de Saint-Exupery)

On Sun, Apr 13, 2008 at 08:13:51PM -0700, Vadim Zaliva wrote:
I guess my main complaint is that in some cases message is not a coherent English phrase, something I can show to users. So I would prefer to have "Error during call to XXX" instead of just "XXX".
[Not a direct answer about the Ruby bindings, but ...] virterror is a confusing and over-engineered bit of code. It would have been better just to raise string errors (as in Perl). But anyway if you can call __virErrorMsg then you should be able to translate the message into something (a) readable and (b) translated. eg. Code in libvirt which does this: qemudReportError (dom->conn, dom, NULL, VIR_ERR_NO_SUPPORT, "%s", __FUNCTION__); should be translated like this in __virErrorMsg (note '_' which means it gets translated): _("this function is not supported by the hypervisor: %s") Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top

On Sun, 2008-04-13 at 20:13 -0700, Vadim Zaliva wrote:
I guess my main complaint is that in some cases message is not a coherent English phrase, something I can show to users. So I would prefer to have "Error during call to XXX" instead of just "XXX".
I just committed a change so that the message of the exception is set to such a message. David
participants (3)
-
David Lutterkort
-
Richard W.M. Jones
-
Vadim Zaliva