|
4 | 4 | try: |
5 | 5 | from confluent_kafka.schema_registry import SchemaRegistryClient |
6 | 6 | _SCHEMA_REGISTRY_CLIENT_AVAILABLE = True |
7 | | -except ImportError: |
| 7 | + _SCHEMA_REGISTRY_IMPORT_ERROR = None |
| 8 | +except ImportError as e: |
| 9 | + _SCHEMA_REGISTRY_IMPORT_ERROR = e |
8 | 10 | _SCHEMA_REGISTRY_CLIENT_AVAILABLE = False |
9 | | - raise ImportError("SchemaRegistry requires additional dependencies to be installed. \ |
10 | | - Please install with 'pip install robotframework-confluentkafkalibrary[schemaregistry]'") |
11 | 11 |
|
12 | 12 | from confluent_kafka.admin import AdminClient, NewTopic, NewPartitions, ConfigResource |
13 | 13 | from robot.libraries.BuiltIn import BuiltIn, RobotNotRunningError |
|
21 | 21 | try: |
22 | 22 | from .serialization import Serializer, Deserializer |
23 | 23 | IMPORTS += Serializer, Deserializer |
24 | | - except ImportError: |
| 24 | + except ImportError as e: |
| 25 | + print(e) |
25 | 26 | pass |
26 | 27 |
|
27 | 28 | #class ConfluentKafkaLibrary(KafkaConsumer, KafkaProducer, Serializer, Deserializer): |
@@ -140,4 +141,11 @@ def config_resource(self, restype, name, **kwargs): |
140 | 141 | return ConfigResource(restype=restype, name=name, **kwargs) |
141 | 142 |
|
142 | 143 | def get_schema_registry_client(self, conf): |
| 144 | + if not _SCHEMA_REGISTRY_CLIENT_AVAILABLE: |
| 145 | + raise ImportError( |
| 146 | + "SchemaRegistry requires additional dependencies to be installed or one of its transitive dependencies is missing. " |
| 147 | + "Please install with 'pip install robotframework-confluentkafkalibrary[schemaregistry]'.\n" |
| 148 | + "If the error persists, check for missing dependencies in your environment.\n" |
| 149 | + f"ImportError: {_SCHEMA_REGISTRY_IMPORT_ERROR}" |
| 150 | + ) |
143 | 151 | return SchemaRegistryClient(conf) |
0 commit comments