Reviewed-By: Ramon Medeiros <ramonn(a)br.ibm.com>
On 02/10/2017 03:03 PM, Lucio Correia wrote:
When new args are added to existing error messages, expansion of
old log entries for that message will fail due to lack of new
arg. Fix that by ignoring KeyError execptions.
Signed-off-by: Lucio Correia <luciojhc(a)linux.vnet.ibm.com>
---
src/wok/message.py | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/src/wok/message.py b/src/wok/message.py
index ff4cbc9..f39701c 100644
--- a/src/wok/message.py
+++ b/src/wok/message.py
@@ -86,7 +86,16 @@ class WokMessage(object):
def get_text(self, prepend_code=True, translate=True):
msg = self._get_text(translate)
- msg = decode_value(msg) % self.args
+
+ try:
+ msg = decode_value(msg) % self.args
+ except KeyError, e:
+ # When new args are added to existing log messages, old entries in
+ # log for the same message would fail due to lack of that new arg.
+ # This avoids whole log functionality to break due to that, while
+ # registers the problem.
+ msg = decode_value(msg)
+ cherrypy.log.error_log.error("KeyError: %s - %s" % (str(e), msg))
if prepend_code:
return "%s: %s" % (self.code, msg)