Internationalization for public errors

Currently, we throw many public exceptions without proper i18n.
Wrap natural-language error messages in _() so they can be translated.

In the service plugin, raise NotFound errors using handle_not_found helper
so the error message contains the offending service.

Use ScriptError instead of NotFoundError in bindinstance install.

https://fedorahosted.org/freeipa/ticket/1953
This commit is contained in:
Petr Viktorin
2012-07-04 08:52:47 -04:00
committed by Martin Kosek
parent 4f03aed5e6
commit a95eaeac8e
30 changed files with 175 additions and 123 deletions

View File

@@ -17,15 +17,17 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from ipalib import api, errors
import httplib
import xml.dom.minidom
from ipapython import nsslib, ipautil
import nss.nss as nss
from nss.error import NSPRError
from ipalib.errors import NetworkError, CertificateOperationError
from urllib import urlencode
from ipalib import api, errors
from ipapython import nsslib, ipautil
from ipalib.errors import NetworkError, CertificateOperationError
from ipapython.ipa_log_manager import *
from ipalib.text import _
def get_ca_certchain(ca_host=None):
"""
@@ -52,12 +54,14 @@ def get_ca_certchain(ca_host=None):
reason = item_node[0].childNodes[0].data
raise errors.RemoteRetrieveError(reason=reason)
except Exception, e:
raise errors.RemoteRetrieveError(reason="Retrieving CA cert chain failed: %s" % str(e))
raise errors.RemoteRetrieveError(
reason=_("Retrieving CA cert chain failed: %s") % e)
finally:
if doc:
doc.unlink()
else:
raise errors.RemoteRetrieveError(reason="request failed with HTTP status %d" % res.status)
raise errors.RemoteRetrieveError(
reason=_("request failed with HTTP status %d") % res.status)
return chain