<html><body>
<p>+1<br>
<br>
The exception is used for flow control when it happens. yes, that's right but not completed.:-)<br>
When you look into the current design of exceptions such as nova exceptions, they include message content which is meaningful and useful. Apparently, the exception is not only used for flow control, but also for showing user why this could happen. It is not bad smell for code or conflict with MVC design pattern, I think. Add another separate layer is complex and not necessary. The gettext tookit allow the message to be translated or untranslated. It depends on the user requirements on this that we can't ignore.<br>
<br>
nova/nova/exception.py:<br>
...<br>
<font color="#0000FF" face="Monospace">class</font><font color="#2F2F2F" face="Monospace"> </font><b><font face="Monospace">DecryptionFailure</font></b><font face="Monospace">(NovaException):</font><br>
<font color="#2F2F2F" face="Monospace">    </font><font face="Monospace">message</font><font color="#2F2F2F" face="Monospace"> </font><font face="Monospace">=</font><font color="#2F2F2F" face="Monospace"> </font><font face="Monospace">_(</font><i><font color="#00A000" face="Monospace">"Failed to </font></i><i><u><font color="#00A000" face="Monospace">decrypt</font></u></i><i><font color="#00A000" face="Monospace"> text"</font></i><font face="Monospace">)</font><br>
<br>
<br>
<font color="#0000FF" face="Monospace">class</font><font color="#2F2F2F" face="Monospace"> </font><b><font face="Monospace">ImagePaginationFailed</font></b><font face="Monospace">(NovaException):</font><br>
<font color="#2F2F2F" face="Monospace">    </font><font face="Monospace">message</font><font color="#2F2F2F" face="Monospace"> </font><font face="Monospace">=</font><font color="#2F2F2F" face="Monospace"> </font><font face="Monospace">_(</font><i><font color="#00A000" face="Monospace">"Failed to paginate through images from image service"</font></i><font face="Monospace">)</font><br>
<br>
<br>
<font color="#0000FF" face="Monospace">class</font><font color="#2F2F2F" face="Monospace"> </font><b><font face="Monospace">VirtualInterfaceCreateException</font></b><font face="Monospace">(NovaException):</font><br>
<font color="#2F2F2F" face="Monospace">    </font><font face="Monospace">message</font><font color="#2F2F2F" face="Monospace"> </font><font face="Monospace">=</font><font color="#2F2F2F" face="Monospace"> </font><font face="Monospace">_(</font><i><font color="#00A000" face="Monospace">"Virtual Interface creation failed"</font></i><font face="Monospace">)</font><br>
<br>
<br>
<font color="#0000FF" face="Monospace">class</font><font color="#2F2F2F" face="Monospace"> </font><b><font face="Monospace">VirtualInterfaceMacAddressException</font></b><font face="Monospace">(NovaException):</font><br>
<font color="#2F2F2F" face="Monospace">    </font><font face="Monospace">message</font><font color="#2F2F2F" face="Monospace"> </font><font face="Monospace">=</font><font color="#2F2F2F" face="Monospace"> </font><font face="Monospace">_(</font><i><font color="#00A000" face="Monospace">"5 attempts to create virtual interface"</font></i><br>
<font color="#2F2F2F" face="Monospace">                </font><i><font color="#00A000" face="Monospace">"with unique </font></i><i><u><font color="#00A000" face="Monospace">mac</font></u></i><i><font color="#00A000" face="Monospace"> address failed"</font></i><font face="Monospace">)</font><br>
<br>
<br>
<font color="#0000FF" face="Monospace">class</font><font color="#2F2F2F" face="Monospace"> </font><b><font face="Monospace">GlanceConnectionFailed</font></b><font face="Monospace">(NovaException):</font><br>
<font color="#2F2F2F" face="Monospace">    </font><font face="Monospace">message</font><font color="#2F2F2F" face="Monospace"> </font><font face="Monospace">=</font><font color="#2F2F2F" face="Monospace"> </font><font face="Monospace">_(</font><i><font color="#00A000" face="Monospace">"Connection to glance failed"</font></i><font face="Monospace">)</font><font color="#2F2F2F" face="Monospace"> </font><font face="Monospace">+</font><font color="#2F2F2F" face="Monospace"> </font><i><font color="#00A000" face="Monospace">": %(reason)s"</font></i><br>
<br>
<br>
<font color="#0000FF" face="Monospace">class</font><font color="#2F2F2F" face="Monospace"> </font><b><font face="Monospace">MelangeConnectionFailed</font></b><font face="Monospace">(NovaException):</font><br>
<font color="#2F2F2F" face="Monospace">    </font><font face="Monospace">message</font><font color="#2F2F2F" face="Monospace"> </font><font face="Monospace">=</font><font color="#2F2F2F" face="Monospace"> </font><font face="Monospace">_(</font><i><font color="#00A000" face="Monospace">"Connection to </font></i><i><u><font color="#00A000" face="Monospace">melange</font></u></i><i><font color="#00A000" face="Monospace"> failed"</font></i><font face="Monospace">)</font><font color="#2F2F2F" face="Monospace"> </font><font face="Monospace">+</font><font color="#2F2F2F" face="Monospace"> </font><i><font color="#00A000" face="Monospace">": %(reason)s"</font></i><br>
...<br>
<br>
<br>
<br>
<b><font size="2">Best Regards, </font></b><font size="2"><br>
<br>
</font><hr width="100%" size="2" align="left">
<table border="0" cellspacing="0" cellpadding="0">
<tr valign="top"><td width="298" valign="middle"><b><font size="2">Edward Zhang(张华)</font></b><font size="2"><br>
Staff Software Engineer<br>
Travel&Transportation Standards<br>
Emerging Technology Institute(ETI)<br>
IBM China Software Development Lab<br>
e-mail: zhuadl@cn.ibm.com<br>
Notes ID: Hua ZZ Zhang/China/IBM<br>
Tel: 86-10-82450483</font></td><td width="298" valign="middle"><font size="2">地址:北京市海淀区东北旺西路8号 中关村软件园28号楼 环宇大厦3层 邮编:100193<br>
Address: 3F Ring, Building 28 Zhongguancun Software Park, 8 Dongbeiwang West Road, Haidian District, Beijing, P.R.C.100193</font></td></tr>

<tr valign="top"><td width="298" valign="middle"><img src="cid:1__=C7BBF371DFA1868C8f9e8a93df938@cn.ibm.com" width="100" height="100"></td><td width="298" valign="middle"><img width="1" height="1" src="cid:2__=C7BBF371DFA1868C8f9e8a93df938@cn.ibm.com" border="0" alt=""></td></tr>

<tr valign="top"><td width="298" valign="middle"><font size="1"><br>
</font></td><td width="298" valign="middle"><img width="1" height="1" src="cid:2__=C7BBF371DFA1868C8f9e8a93df938@cn.ibm.com" border="0" alt=""></td></tr>
</table>
<br>
<img width="16" height="16" src="cid:3__=C7BBF371DFA1868C8f9e8a93df938@cn.ibm.com" border="0" alt="Inactive hide details for Joshua Harlow ---2012-04-13 01:33:18---So u have just touched on another issue,"><font color="#424282">Joshua Harlow ---2012-04-13 01:33:18---So u have just touched on another issue,</font><br>
<br>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign="top"><td style="background-image:url(cid:4__=C7BBF371DFA1868C8f9e8a93df938@cn.ibm.com); background-repeat: no-repeat; " width="40%">
<ul>
<ul>
<ul>
<ul><b><font size="2">Joshua Harlow <harlowja@yahoo-inc.com></font></b><font size="2"> </font>
<p><font size="2">2012-04-13 01:33</font></ul>
</ul>
</ul>
</ul>
</td><td width="60%">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign="top"><td width="1%"><img width="58" height="1" src="cid:2__=C7BBF371DFA1868C8f9e8a93df938@cn.ibm.com" border="0" alt=""><br>
<div align="right"><font size="2">To</font></div></td><td width="100%"><img width="1" height="1" src="cid:2__=C7BBF371DFA1868C8f9e8a93df938@cn.ibm.com" border="0" alt=""><br>
<font size="2">Hua ZZ Zhang/China/IBM@IBMCN, Thierry Carrez <thierry@openstack.org></font></td></tr>

<tr valign="top"><td width="1%"><img width="58" height="1" src="cid:2__=C7BBF371DFA1868C8f9e8a93df938@cn.ibm.com" border="0" alt=""><br>
<div align="right"><font size="2">cc</font></div></td><td width="100%"><img width="1" height="1" src="cid:2__=C7BBF371DFA1868C8f9e8a93df938@cn.ibm.com" border="0" alt=""><br>
<font size="2">"openstack-bounces+zhuadl=cn.ibm.com@lists.launchpad.net"      <openstack-bounces+zhuadl=cn.ibm.com@lists.launchpad.net>, openstack <openstack@lists.launchpad.net></font></td></tr>

<tr valign="top"><td width="1%"><img width="58" height="1" src="cid:2__=C7BBF371DFA1868C8f9e8a93df938@cn.ibm.com" border="0" alt=""><br>
<div align="right"><font size="2">Subject</font></div></td><td width="100%"><img width="1" height="1" src="cid:2__=C7BBF371DFA1868C8f9e8a93df938@cn.ibm.com" border="0" alt=""><br>
<font size="2">Re: [Openstack] I18n issue for OpenStack</font></td></tr>
</table>

<table border="0" cellspacing="0" cellpadding="0">
<tr valign="top"><td width="58"><img width="1" height="1" src="cid:2__=C7BBF371DFA1868C8f9e8a93df938@cn.ibm.com" border="0" alt=""></td><td width="336"><img width="1" height="1" src="cid:2__=C7BBF371DFA1868C8f9e8a93df938@cn.ibm.com" border="0" alt=""></td></tr>
</table>
</td></tr>
</table>
<br>
<font face="Calibri">So u have just touched on another issue,<br>
<br>
I would still say that exception messages should not be translated (+1), haha.<br>
<br>
If this is needed, then there is something wrong with the code and how exceptions are used instead (ie the bad code smell). Exceptions should be meant for error control flow, what they were designed for, not for user facing messages. I think it is more common to have a layer that translates exceptions into meaningful localized messages, but there needs to be a separation between exceptions and there localized messages (they should not be combined). This is a common thing afaik, its called separation of model and view, aka, mvc, (think of the exceptions as a model/controller(?), if the messages – the view are intertwined that seems broke). <br>
<br>
This is common with a lot of other parts of openstack as well, ec2 formatting/response creation should be separated from nova logic (ec2 should be a view, which it mostly is right now) and so on...<br>
<br>
On 4/12/12 4:27 AM, "Hua ZZ Zhang" <</font><a href="zhuadl@cn.ibm.com"><u><font color="#0000FF" face="Calibri">zhuadl@cn.ibm.com</font></u></a><font face="Calibri">> wrote:<br>
</font>
<ul>
<ul><font face="Consolas">My cents:</font><font face="Calibri"><br>
</font><font face="Consolas"><br>
Apache HTTP is not so equivelant to OpenStack here. Generally it doesn't care about the application errors or exceptions thrown by web applications. In openstack, exceptions have been defined in nova, horizon, keystone etc. The messages of these exceptions are important for different users to understand what has happened. These messages always need to be localized, returned and displayed on user interface, not just be logged in backend system. It is very common practice for a global software project.</font><font face="Calibri"><br>
</font><font face="Consolas"><br>
Sean Dague wrote:<br>
> If we want to think about OpenStack as a basic building block like<br>
> Apache, i18n is critical. Otherwise there are regions that won't adopt<br>
> it solely because of a lack of i18n.<br>
<br>
Note that Apache HTTPd, for instance, does not seem to internationalize<br>
its error messages. Only the (enduser-facing) HTML pages it gives back<br>
in response to invalid requests are.<br>
</font><font face="Calibri"><br>
<br>
</font><b><font face="Calibri"><br>
Best Regards, </font></b><font face="Calibri"><br>
<br>
</font><hr width="100%" size="2" align="left"><b><font face="Calibri">Edward Zhang(张华)</font></b><font face="Calibri"><br>
Staff Software Engineer<br>
Travel&Transportation Standards<br>
Emerging Technology Institute(ETI)<br>
IBM China Software Development Lab<br>
e-mail: </font><a href="zhuadl@cn.ibm.com"><u><font color="#0000FF" face="Calibri">zhuadl@cn.ibm.com</font></u></a><font face="Calibri"><br>
Notes ID: Hua ZZ Zhang/China/IBM<br>
Tel: 86-10-82450483地址:北京市海淀区东北旺西路8号 中关村软件园28号楼 环宇大厦3层 邮编:100193<br>
Address: 3F Ring, Building 28 Zhongguancun Software Park, 8 Dongbeiwang West Road, Haidian District, Beijing, P.R.C.100193 <br>
</font><img src="cid:1__=C7BBF371DFA1868C8f9e8a93df938@cn.ibm.com" width="100" height="100"><img src="cid:2__=C7BBF371DFA1868C8f9e8a93df938@cn.ibm.com" width="16" height="1"><font face="Calibri"><br>
</font><font face="Calibri"><br>
</font><img src="cid:2__=C7BBF371DFA1868C8f9e8a93df938@cn.ibm.com" width="16" height="1"><font face="Calibri"><br>
</font><img src="cid:3__=C7BBF371DFA1868C8f9e8a93df938@cn.ibm.com" width="16" height="16"><font color="#424282" face="Calibri">Thierry Carrez ---2012-04-12 16:51:59---Sean Dague wrote:</font><font face="Calibri"><br>
</font>
<ul>
<ul>
<ul>
<ul>
<ul>
<ul>
<ul>
<ul><b><font face="Calibri">Thierry Carrez <</font></b><a href="thierry@openstack.org"><b><u><font color="#0000FF" face="Calibri">thierry@openstack.org</font></u></b></a><b><font face="Calibri">></font></b><font face="Calibri"> <br>
Sent by: </font><a href="openstack-bounces+zhuadl=cn.ibm.com@lists.launchpad.net"><u><font color="#0000FF" face="Calibri">openstack-bounces+zhuadl=cn.ibm.com@lists.launchpad.net</font></u></a><font face="Calibri"> 2012-04-12 16:47</font></ul>
</ul>
</ul>
</ul>
</ul>
</ul>
</ul>
</ul>
<img src="cid:2__=C7BBF371DFA1868C8f9e8a93df938@cn.ibm.com" width="16" height="1"></ul>
</ul>
<div align="right"><font face="Calibri">To </font></div>
<ul>
<ul><img src="cid:2__=C7BBF371DFA1868C8f9e8a93df938@cn.ibm.com" width="16" height="1"><u><font color="#0000FF" face="Calibri"><br>
</font></u><a href="openstack@lists.launchpad.net"><u><font color="#0000FF" face="Calibri">openstack@lists.launchpad.net</font></u></a><font face="Calibri"> <br>
</font><img src="cid:2__=C7BBF371DFA1868C8f9e8a93df938@cn.ibm.com" width="16" height="1"></ul>
</ul>
<div align="right"><font face="Calibri">cc </font></div>
<ul>
<ul><img src="cid:2__=C7BBF371DFA1868C8f9e8a93df938@cn.ibm.com" width="16" height="1"><font face="Calibri"><br>
</font><img src="cid:2__=C7BBF371DFA1868C8f9e8a93df938@cn.ibm.com" width="16" height="1"></ul>
</ul>
<div align="right"><font face="Calibri">Subject </font></div>
<ul>
<ul><img src="cid:2__=C7BBF371DFA1868C8f9e8a93df938@cn.ibm.com" width="16" height="1"><font face="Calibri"><br>
Re: [Openstack] I18n issue for OpenStack <br>
</font><img src="cid:2__=C7BBF371DFA1868C8f9e8a93df938@cn.ibm.com" width="16" height="1"><img src="cid:2__=C7BBF371DFA1868C8f9e8a93df938@cn.ibm.com" width="16" height="1"><font face="Consolas"><br>
Sean Dague wrote:<br>
> If we want to think about OpenStack as a basic building block like<br>
> Apache, i18n is critical. Otherwise there are regions that won't adopt<br>
> it solely because of a lack of i18n.<br>
<br>
Note that Apache HTTPd, for instance, does not seem to internationalize<br>
its error messages. Only the (enduser-facing) HTML pages it gives back<br>
in response to invalid requests are.<br>
<br>
> Is there a metric on the completeness so far? Something automated that<br>
> could be a jenkins coverage kind of test?<br>
<br>
Oddly enough, it's not a question of completeness of translations.<br>
Piggybacking on the awesome Launchpad Translations community always gave<br>
us great coverage. It's more a code support and CI integration issue.</font>
<p></ul>
</ul>
</body></html>