<p dir="ltr">Or even better, we map all code and messages on UI (i18n.html) and backend returns the code and params. </p>
<p dir="ltr">For example:<br>
KimchiError('VMERRO01', 'my-vm') </p>
<p dir="ltr">And on UI:<br>
i18n[code], params </p>
<p dir="ltr">That way the translation will be done just in one place - UI </p>
<p dir="ltr">But while using the REST API we will return code and params - not a full message. <br>
(I am not sure I like it) </p>
<p dir="ltr">What do you think about those 2 proposals? <br>
</p>
<div class="gmail_quote">On Jan 31, 2014 4:21 PM, "Aline Manera" <<a href="mailto:alinefm@linux.vnet.ibm.com">alinefm@linux.vnet.ibm.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
From: Aline Manera <<a href="mailto:alinefm@br.ibm.com">alinefm@br.ibm.com</a>><br>
<br>
Hi all,<br>
<br>
This is the RFC for the refactor exception task.<br>
Sheldon has already done something related to that some time ago.<br>
<br>
He also created a wiki for that:<br>
- <a href="https://github.com/kimchi-project/kimchi/wiki/refactor-exception" target="_blank">https://github.com/kimchi-project/kimchi/wiki/refactor-exception</a><br>
<br>
The only change I made in him approach is translating the message in backend<br>
and send it to UI<br>
That way we don't need to duplicate the messages on backend and UI (as it is<br>
explained on wiki)<br>
<br>
The steps to get it done:<br>
1) Change cherrypy error handler to send the exception data to UI<br>
2) Create a common Exception class (KimchiError) to translate the error message<br>
and proper set the parameters<br>
3) Update UI to show the message received from backend to the user<br>
<br>
I also would like to create a file on backend: __messages__.py which will<br>
contain all messages used on backend.<br>
For example:<br>
<br>
# __messages__.py<br>
VM_START_FAILED = "<code>: Failed to start virtual machine %(name)s"<br>
<br>
The contants names should be: <resource>_<action>_<error><br>
<br>
The <code> need to be a unique value between all messages.<br>
It is needed in order to we identify the error independent of the message<br>
language.<br>
That way a user running Kimchi in German can easily post his error on mail list<br>
or github, and we can identify where the problem is by the message code.<br>
<br>
I also will add this code in the UI messages.<br>
<br>
For the code, we can build it like: <resource><BACK|UI><type-of-error><ident><br>
And on backend:<br>
<br>
VMBACKINFO01<br>
VMBACKERRO01<br>
VMBACKWARN01<br>
<br>
And on UI:<br>
<br>
VMUIINFO01<br>
VMUIERRO01<br>
VMUIWARN01<br>
<br>
So we will also need:<br>
4) Create a __messages__ file with all messages used on backend<br>
5) Update build process to add the messages in this file to .po files<br>
6) Update UI messages to add a code for them<br>
<br>
I made a small patch set with my proposal.<br>
This patch set does not include the items 4,5 and 6<br>
In fact, I used an existent message for test (as you can notice on patches)<br>
And *just for example* it will *always* raise an exception while starting a VM.<br>
<br>
Any comments/suggestions are welcome. =)<br>
<br>
Aline Manera (2):<br>
refactor exception: Create a common Exception to translate error<br>
messages<br>
refator exception: Example of use<br>
<br>
ShaoHe Feng (1):<br>
refactor exception: Add a kimchi special error handler<br>
<br>
src/kimchi/control/base.py | 5 ++++-<br>
src/kimchi/exception.py | 29 ++++++++++++++++++++++-------<br>
src/kimchi/model/vms.py | 4 +++-<br>
src/kimchi/template.py | 14 ++++++++++++++<br>
ui/js/src/kimchi.guest_main.js | 4 ++--<br>
5 files changed, 45 insertions(+), 11 deletions(-)<br>
<br>
--<br>
1.7.10.4<br>
<br>
_______________________________________________<br>
Kimchi-devel mailing list<br>
<a href="mailto:Kimchi-devel@ovirt.org">Kimchi-devel@ovirt.org</a><br>
<a href="http://lists.ovirt.org/mailman/listinfo/kimchi-devel" target="_blank">http://lists.ovirt.org/mailman/listinfo/kimchi-devel</a><br>
</blockquote></div>