[Bf-extensions-cvs] [351de35b] master: BlenderKit: improve error handling of some cases.

Vilém Duha noreply at git.blender.org
Wed Sep 30 15:51:42 CEST 2020


Commit: 351de35b968e5a49789851c3c90559dbe8afa5cd
Author: Vilém Duha
Date:   Wed Sep 30 14:50:06 2020 +0200
Branches: master
https://developer.blender.org/rBA351de35b968e5a49789851c3c90559dbe8afa5cd

BlenderKit: improve error handling of some cases.

===================================================================

M	blenderkit/__init__.py
M	blenderkit/download.py
M	blenderkit/search.py

===================================================================

diff --git a/blenderkit/__init__.py b/blenderkit/__init__.py
index 9294e44b..c6aa82d7 100644
--- a/blenderkit/__init__.py
+++ b/blenderkit/__init__.py
@@ -19,7 +19,7 @@
 bl_info = {
     "name": "BlenderKit Online Asset Library",
     "author": "Vilem Duha, Petr Dlouhy",
-    "version": (1, 0, 31),
+    "version": (1, 0, 32),
     "blender": (2, 83, 0),
     "location": "View3D > Properties > BlenderKit",
     "description": "Online BlenderKit library (materials, models, brushes and more). Connects to the internet.",
diff --git a/blenderkit/download.py b/blenderkit/download.py
index 1e028e4a..a80678fc 100644
--- a/blenderkit/download.py
+++ b/blenderkit/download.py
@@ -859,6 +859,7 @@ def get_download_url(asset_data, scene_id, api_key, tcom=None):
             tcom.error = True
         return 'Connection Error'
 
+
     if r.status_code < 400:
         data = r.json()
         url = data['filePath']
diff --git a/blenderkit/search.py b/blenderkit/search.py
index 18a6aeae..0af69dd8 100644
--- a/blenderkit/search.py
+++ b/blenderkit/search.py
@@ -64,7 +64,7 @@ prev_time = 0
 
 
 def check_errors(rdata):
-    if rdata.get('statusCode') == 401:
+    if rdata.get('statusCode') and int(rdata.get('statusCode')) > 299:
         utils.p(rdata)
         if rdata.get('detail') == 'Invalid token.':
             user_preferences = bpy.context.preferences.addons['blenderkit'].preferences
@@ -73,6 +73,8 @@ def check_errors(rdata):
                     bkit_oauth.refresh_token_thread()
                 return False, rdata.get('detail')
             return False, 'Use login panel to connect your profile.'
+        else:
+            return False, rdata.get('detail')
     return True, ''
 
 
@@ -899,7 +901,13 @@ class Searcher(threading.Thread):
             print(inst)
 
         mt('data parsed ')
-
+        if not rdata.get('results'):
+            utils.pprint(rdata)
+            # if the result was converted to json and didn't return results,
+            # it means it's a server error that has a clear message.
+            # That's why it gets processed in the update timer, where it can be passed in messages to user.
+            self.result = rdata
+            return
         # print('number of results: ', len(rdata.get('results', [])))
         if self.stopped():
             utils.p('stopping search : ' + str(query))



More information about the Bf-extensions-cvs mailing list