diff --git a/trustgraph-base/trustgraph/api/api.py b/trustgraph-base/trustgraph/api/api.py index 0190d3f5..3a091b3b 100644 --- a/trustgraph-base/trustgraph/api/api.py +++ b/trustgraph-base/trustgraph/api/api.py @@ -25,7 +25,7 @@ def check_error(response): try: msg = response["error"]["message"] tp = response["error"]["type"] - except: + except KeyError: raise ApplicationException(response["error"]) raise ApplicationException(f"{tp}: {msg}") @@ -208,7 +208,7 @@ class Api: try: # Parse the response as JSON object = resp.json() - except: + except ValueError: raise ProtocolException(f"Expected JSON response") check_error(object) diff --git a/trustgraph-base/trustgraph/api/async_flow.py b/trustgraph-base/trustgraph/api/async_flow.py index 97167c81..68d7cd86 100644 --- a/trustgraph-base/trustgraph/api/async_flow.py +++ b/trustgraph-base/trustgraph/api/async_flow.py @@ -25,7 +25,7 @@ def check_error(response): try: msg = response["error"]["message"] tp = response["error"]["type"] - except: + except KeyError: raise ApplicationException(response["error"]) raise ApplicationException(f"{tp}: {msg}") @@ -88,7 +88,7 @@ class AsyncFlow: try: obj = await resp.json() - except: + except (ValueError, aiohttp.ContentTypeError): raise ProtocolException(f"Expected JSON response") check_error(obj) diff --git a/trustgraph-base/trustgraph/api/async_socket_client.py b/trustgraph-base/trustgraph/api/async_socket_client.py index 4ba3795b..3d1030ef 100644 --- a/trustgraph-base/trustgraph/api/async_socket_client.py +++ b/trustgraph-base/trustgraph/api/async_socket_client.py @@ -142,7 +142,7 @@ class AsyncSocketClient: for queue in self._pending.values(): try: await queue.put({"error": str(e)}) - except: + except asyncio.CancelledError : pass finally: self._connected = False diff --git a/trustgraph-base/trustgraph/api/bulk_client.py b/trustgraph-base/trustgraph/api/bulk_client.py index ae185240..452df7ea 100644 --- a/trustgraph-base/trustgraph/api/bulk_client.py +++ b/trustgraph-base/trustgraph/api/bulk_client.py @@ -201,7 +201,7 @@ class BulkClient: finally: try: loop.run_until_complete(async_gen.aclose()) - except: + except Exception: pass async def _export_triples_async(self, flow: str) -> Iterator[Triple]: @@ -299,7 +299,7 @@ class BulkClient: finally: try: loop.run_until_complete(async_gen.aclose()) - except: + except Exception: pass async def _export_graph_embeddings_async(self, flow: str) -> Iterator[Dict[str, Any]]: @@ -393,7 +393,7 @@ class BulkClient: finally: try: loop.run_until_complete(async_gen.aclose()) - except: + except Exception: pass async def _export_document_embeddings_async(self, flow: str) -> Iterator[Dict[str, Any]]: @@ -517,7 +517,7 @@ class BulkClient: finally: try: loop.run_until_complete(async_gen.aclose()) - except: + except Exception: pass async def _export_entity_contexts_async(self, flow: str) -> Iterator[Dict[str, Any]]: diff --git a/trustgraph-base/trustgraph/api/config.py b/trustgraph-base/trustgraph/api/config.py index 5f17672f..10a9f16e 100644 --- a/trustgraph-base/trustgraph/api/config.py +++ b/trustgraph-base/trustgraph/api/config.py @@ -254,7 +254,7 @@ class Config: ) for v in object["values"] ] - except: + except (KeyError, TypeError): raise ProtocolException(f"Response not formatted correctly") def get_values_all_workspaces(self, type): @@ -330,6 +330,6 @@ class Config: try: return object["config"], object["version"] - except: + except KeyError: raise ProtocolException(f"Response not formatted correctly")