The framework only shows traceback for the internal/unknown errors,
recognized PublicErrors are simply passed back to the FreeIPA
clients.

However, sometimes it would help to see a traceback of the
PublicError to for example see exactly which line returns it.

https://fedorahosted.org/freeipa/ticket/4847

----

"if api.env.debug" may seem redundant in this case, my motivation was not to
invoke exception trace formatting every time a public error is thrown even when
debug is not enabled.

Martin
From 36b926bce1117d7ea370b8a75890c9711450fb5a Mon Sep 17 00:00:00 2001
From: Martin Kosek <mko...@redhat.com>
Date: Tue, 20 Jan 2015 23:13:23 +0100
Subject: [PATCH] Print PublicError traceback when in debug mode

The framework only shows traceback for the internal/unknown errors,
recognized PublicErrors are simply passed back to the FreeIPA
clients.

However, sometimes it would help to see a traceback of the
PublicError to for example see exactly which line returns it.

https://fedorahosted.org/freeipa/ticket/4847
---
 ipaserver/rpcserver.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/ipaserver/rpcserver.py b/ipaserver/rpcserver.py
index 18de23d3a5bed485d35adb18b22d04255f933448..d6bc955b9d9910a24eec5df1def579310eb54786 100644
--- a/ipaserver/rpcserver.py
+++ b/ipaserver/rpcserver.py
@@ -29,6 +29,7 @@
 import datetime
 import urlparse
 import json
+import traceback
 
 import ldap.controls
 from pyasn1.type import univ, namedtype
@@ -347,6 +348,8 @@ def wsgi_execute(self, environ):
             else:
                 result = self.Command[name](*args, **options)
         except PublicError, e:
+            if self.api.env.debug:
+                self.debug('WSGI wsgi_execute PublicError: %s', traceback.format_exc())
             error = e
         except StandardError, e:
             self.exception(
-- 
1.9.3

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to