|
3 | 3 |
|
4 | 4 | from . import schema
|
5 | 5 | from .base import StoreProvider
|
6 |
| -from .exceptions import ConfigurationError |
| 6 | +from .exceptions import ConfigurationStoreError |
7 | 7 |
|
8 | 8 | logger = logging.getLogger(__name__)
|
9 | 9 |
|
@@ -103,8 +103,8 @@ def get_configuration(self) -> Union[Dict[str, Dict], Dict]:
|
103 | 103 |
|
104 | 104 | Raises
|
105 | 105 | ------
|
106 |
| - ConfigurationError |
107 |
| - Any validation error |
| 106 | + ConfigurationStoreError |
| 107 | + Any propagated error from store |
108 | 108 | SchemaValidationError
|
109 | 109 | When schema doesn't conform with feature flag schema
|
110 | 110 |
|
@@ -140,7 +140,10 @@ def get_configuration(self) -> Union[Dict[str, Dict], Dict]:
|
140 | 140 | """
|
141 | 141 | # parse result conf as JSON, keep in cache for max age defined in store
|
142 | 142 | logger.debug(f"Fetching schema from registered store, store={self._store}")
|
143 |
| - config = self._store.get_configuration() |
| 143 | + try: |
| 144 | + config = self._store.get_configuration() |
| 145 | + except Exception as err: |
| 146 | + raise ConfigurationStoreError("Unable to fetch schema from registered store") from err |
144 | 147 |
|
145 | 148 | validator = schema.SchemaValidator(schema=config)
|
146 | 149 | validator.validate()
|
@@ -183,7 +186,7 @@ def evaluate(self, *, name: str, context: Optional[Dict[str, Any]] = None, defau
|
183 | 186 |
|
184 | 187 | try:
|
185 | 188 | features = self.get_configuration()
|
186 |
| - except ConfigurationError as err: |
| 189 | + except ConfigurationStoreError as err: |
187 | 190 | logger.debug(f"Failed to fetch feature flags from store, returning default provided, reason={err}")
|
188 | 191 | return default
|
189 | 192 |
|
@@ -234,7 +237,7 @@ def get_enabled_features(self, *, context: Optional[Dict[str, Any]] = None) -> L
|
234 | 237 |
|
235 | 238 | try:
|
236 | 239 | features: Dict[str, Any] = self.get_configuration()
|
237 |
| - except ConfigurationError as err: |
| 240 | + except ConfigurationStoreError as err: |
238 | 241 | logger.debug(f"Failed to fetch feature flags from store, returning empty list, reason={err}")
|
239 | 242 | return features_enabled
|
240 | 243 |
|
|
0 commit comments