dongzhaorui 3 ani în urmă
părinte
comite
edaa4664b7
1 a modificat fișierele cu 9 adăugiri și 5 ștergeri
  1. 9 5
      find_source/common/execptions.py

+ 9 - 5
find_source/common/execptions.py

@@ -1,11 +1,15 @@
 class ExploreDataError(Exception):
 
     def __init__(self, *args, **kwargs):
-        if 'code' not in kwargs and 'reason' not in kwargs:
-            kwargs['code'] = 10000
-            kwargs['reason'] = '未知的异常错误,请手动处理'
-        for key, val in kwargs.items():
-            setattr(self, key, val)
+        self.code = kwargs.get('code', 10000)
+        self.reason = kwargs.get('reason', '未知的数据挖掘错误,请尽快处理')
+
+        if 'code' not in kwargs:
+            kwargs['code'] = self.code
+        if 'reason' not in kwargs:
+            kwargs['reason'] = self.reason
+
+        [setattr(self, key, val) for key, val in kwargs.items()]
         super(ExploreDataError, self).__init__(*args, kwargs)