Hi,
I am little confused about error handling in matahari hence this mail.
Thanks the Zane that he pointed me to libvirt-qmf/src/Exception.h and told me that one can call raiseException() to flag an error.
Looks like I can send a string and an error code in the error message. I see some code in matahari which seems to be putting only an error message string and not an error code in the raised exceptions.
session.raiseException(event, mh_result_to_str(MH_RES_INVALID_ARGS))
Here we seem to be putting only an error string and no error code. So the end user (client of matahari API), is it supposed to parse the error strings to figure out what went wrong. There is no notion of stable error codes?
I also looked at libvirt-qmf and it seems to be putting both error strings and error codes in the raised exception.
raiseException(session, event, err, STATUS_USER + ret);
It seems to be retrieving ret code from libvirt and then adding it to STATUS_USER (0x10000). What is STATUS_USER here? Are we planning to use number below 0x10000 for something else?
Questions.
- Expecting client to parse strings for error handling and not error codes, is that the right thing to do.
- If client is supposed to use error code if avaialable, how these error codes are communicated to client. Client just knows by looking at the code that I am dealing with libvirt-qmf and these are error codes?
- I am assuming that error can happen before a message reaches agent. May be intermediate layers are raising their own exceptions with their own error codes. If yes, how to resolve any possible error code clashing between matahari/qpid and agents.
P.S. I am not subscribed to the list, so please keep me CCed in the response.
Thanks Vivek
On 08/11/11 20:35, Vivek Goyal wrote:
Hi,
I am little confused about error handling in matahari hence this mail.
Thanks the Zane that he pointed me to libvirt-qmf/src/Exception.h and told me that one can call raiseException() to flag an error.
Looks like I can send a string and an error code in the error message. I see some code in matahari which seems to be putting only an error message string and not an error code in the raised exceptions.
You can put anything you like in the exception; it is an object like any other with its own schema.
session.raiseException(event, mh_result_to_str(MH_RES_INVALID_ARGS))
Here we seem to be putting only an error string and no error code. So the end user (client of matahari API), is it supposed to parse the error strings to figure out what went wrong. There is no notion of stable error codes?
Partly this is a holdover from QMFv1, which did not support arbitrary exception schemata.
I also looked at libvirt-qmf and it seems to be putting both error strings and error codes in the raised exception.
raiseException(session, event, err, STATUS_USER + ret);
This is done to maintain some semblance of backward compatibility with libvirt-qpid (which used QMFv1). The exception schema used by libvirt-qmf is designed to result in the same behaviour from Python console applications (e.g. qmf-tool) as would have occurred with libvirt-qpid. Agents with no such backward compatibility requirements need not use this scheme.
It seems to be retrieving ret code from libvirt and then adding it to STATUS_USER (0x10000). What is STATUS_USER here? Are we planning to use number below 0x10000 for something else?
Again, this is for compatibility with the former QMFv1 implementation.
Questions.
- Expecting client to parse strings for error handling and not error codes, is that the right thing to do.
The Right Thing depends on the application for your agent; with QMFv2 you have total flexibility. However you make a good point that we should review the exceptions that are raised by the core Matahari agents to ensure that the design is still appropriate.
- If client is supposed to use error code if avaialable, how these error codes are communicated to client. Client just knows by looking at the code that I am dealing with libvirt-qmf and these are error codes?
Yes.
- I am assuming that error can happen before a message reaches agent. May be intermediate layers are raising their own exceptions with their own error codes. If yes, how to resolve any possible error code clashing between matahari/qpid and agents.
As far as I am aware, a failure to deliver the event does not result in an exception being returned in the console.
regards, Zane.
matahari@lists.fedorahosted.org