#2225 hub: log tracebacks for multicalls
Merged 2 years ago by tkopecek. Opened 2 years ago by tkopecek.
tkopecek/koji issue2204  into  master

file modified
+25 -20
@@ -230,6 +230,29 @@ 

          parser.close()

          return unmarshaller.close(), unmarshaller.getmethodname()

  

+     def _log_exception(self):

+         e_class, e = sys.exc_info()[:2]

+         faultCode = getattr(e_class, 'faultCode', 1)

+         tb_type = context.opts.get('KojiTraceback', None)

+         tb_str = ''.join(traceback.format_exception(*sys.exc_info()))

+         if issubclass(e_class, koji.GenericError):

+             if context.opts.get('KojiDebug'):

+                 if tb_type == "extended":

+                     faultString = koji.format_exc_plus()

+                 else:

+                     faultString = tb_str

+             else:

+                 faultString = str(e)

+         else:

+             if tb_type == "normal":

+                 faultString = tb_str

+             elif tb_type == "extended":

+                 faultString = koji.format_exc_plus()

+             else:

+                 faultString = "%s: %s" % (e_class, e)

+         self.logger.warning(tb_str)

+         return faultCode, faultString

+ 

      def _wrap_handler(self, handler, environ):

          """Catch exceptions and encode response of handler"""

  
@@ -245,26 +268,7 @@ 

          except Exception:

              self.traceback = True

              # report exception back to server

-             e_class, e = sys.exc_info()[:2]

-             faultCode = getattr(e_class, 'faultCode', 1)

-             tb_type = context.opts.get('KojiTraceback', None)

-             tb_str = ''.join(traceback.format_exception(*sys.exc_info()))

-             if issubclass(e_class, koji.GenericError):

-                 if context.opts.get('KojiDebug'):

-                     if tb_type == "extended":

-                         faultString = koji.format_exc_plus()

-                     else:

-                         faultString = tb_str

-                 else:

-                     faultString = str(e)

-             else:

-                 if tb_type == "normal":

-                     faultString = tb_str

-                 elif tb_type == "extended":

-                     faultString = koji.format_exc_plus()

-                 else:

-                     faultString = "%s: %s" % (e_class, e)

-             self.logger.warning(tb_str)

+             faultCode, faultString = self._log_exception()

              response = dumps(Fault(faultCode, faultString), marshaller=Marshaller)

  

          return response
@@ -352,6 +356,7 @@ 

                  results.append({'faultCode': faultCode,

                                  'faultString': faultString,

                                  'traceback': trace})

+                 self._log_exception()

              else:

                  results.append([result])

  

Metadata Update from @tkopecek:
- Pull-request tagged with: testing-ready

2 years ago

Metadata Update from @mfilip:
- Pull-request tagged with: testing-done

2 years ago

Commit 360ccd2 fixes this pull-request

Pull-Request has been merged by tkopecek

2 years ago