Valentin Gorbunov avatar Valentin Gorbunov committed 00e7a78

now all error_data stored in VKError.error

Comments (0)

Files changed (1)

 class VKError(Exception):
-    __slots__ = ["code", "description", "params"]
-    def __init__(self, code, description, params):
-        self.code, self.description, self.params = (code, description, params)
+    __slots__ = ["error"]
+    def __init__(self, code, description=None, params=None):
+        if isinstance(code, dict):
+            self.error = code
+        else:
+            self.error = {
+                'code': code,
+                'description': description,
+                'params': params,
+            }
         Exception.__init__(self, str(self))
+    def _code(self):
+        return self.error['code']
+    code = property(_code)
+    def _description(self):
+        return self.error['description']
+    description = property(_description)
+    def _params(self):
+        return self.error['params']
+    params = property(_params)
     def __str__(self):
         return "Error(code = '%s', description = '%s', params = '%s')" % (self.code, self.description, self.params)
         data = json.loads(response)
         if "error" in data:
-            raise VKError(data["error"]["error_code"], data["error"]["error_msg"], data["error"]["request_params"])
+            raise VKError(data["error"])
         return data['response']
     def __getattr__(self, name):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.