Quellcode durchsuchen

Always log exception traces in error-handling utility decorators.

Nashwan Azhari vor 7 Jahren
Ursprung
Commit
2c6b74ca64
1 geänderte Dateien mit 5 neuen und 3 gelöschten Zeilen
  1. 5 3
      coriolis/utils.py

+ 5 - 3
coriolis/utils.py

@@ -49,8 +49,8 @@ def ignore_exceptions(func):
     def _ignore_exceptions(*args, **kwargs):
     def _ignore_exceptions(*args, **kwargs):
         try:
         try:
             return func(*args, **kwargs)
             return func(*args, **kwargs)
-        except Exception as ex:
-            LOG.exception(ex)
+        except Exception:
+            LOG.warn("Ignoring exception:\n%s", get_exception_details())
     return _ignore_exceptions
     return _ignore_exceptions
 
 
 
 
@@ -87,7 +87,9 @@ def retry_on_error(max_attempts=5, sleep_seconds=0,
 
 
                     i += 1
                     i += 1
                     if i < max_attempts:
                     if i < max_attempts:
-                        LOG.warn("Exception occurred, retrying: %s", ex)
+                        LOG.warn(
+                            "Exception occurred, retrying (%d/%d):\n%s",
+                            i, max_attempts, get_exception_details())
                         time.sleep(sleep_seconds)
                         time.sleep(sleep_seconds)
                     else:
                     else:
                         raise
                         raise