From 72b5cb1f51080345b7155173ebebf08e5183a349 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <piotr.maslanka@henrietta.com.pl>
Date: Wed, 24 Feb 2021 01:30:48 +0100
Subject: [PATCH] fix a bug in CustomException

---
 CHANGELOG.md          |  1 +
 satella/__init__.py   |  2 +-
 satella/exceptions.py | 16 +++++++++++-----
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6b6fba38..e3e33cff 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,4 @@
 # v2.14.46
 
 * added kwargs to ThreadCollection.from_class
+* fixed a bug in CustomException
diff --git a/satella/__init__.py b/satella/__init__.py
index 487574d7..badd3286 100644
--- a/satella/__init__.py
+++ b/satella/__init__.py
@@ -1 +1 @@
-__version__ = '2.14.46a2'
+__version__ = '2.14.46a3'
diff --git a/satella/exceptions.py b/satella/exceptions.py
index 9c96260e..0bea7338 100644
--- a/satella/exceptions.py
+++ b/satella/exceptions.py
@@ -26,8 +26,11 @@ class CustomException(Exception):
 
     def __str__(self) -> str:
         a = '%s(%s' % (self.__class__.__qualname__.split('.')[-1], ', '.join(map(repr, self.args)))
-        if self.kwargs:
-            a += ', ' + ', '.join(map(lambda k, v: '%s=%s' % (k, repr(v)), self.kwargs.items()))
+        try:
+            if self.kwargs:
+                a += ', ' + ', '.join(map(lambda k, v: '%s=%s' % (k, repr(v)), self.kwargs.items()))
+        except AttributeError:
+            pass
         a += ')'
         return a
 
@@ -36,9 +39,12 @@ class CustomException(Exception):
                          if self.__class__.__module__ != 'builtins' else '',
                          self.__class__.__qualname__,
                          ', '.join(map(repr, self.args)))
-        if self.kwargs:
-            a += ', ' + (', '.join(map(lambda kv: '%s=%s' % (kv[0], repr(kv[1])),
-                                       self.kwargs.items())))
+        try:
+            if self.kwargs:
+                a += ', ' + (', '.join(map(lambda kv: '%s=%s' % (kv[0], repr(kv[1])),
+                                           self.kwargs.items())))
+        except AttributeError:
+            pass
         a += ')'
         return a
 
-- 
GitLab