|
3 | 3 | from abc import ABC, abstractmethod
|
4 | 4 | from typing import TYPE_CHECKING, Optional, TypeVar, Union
|
5 | 5 |
|
6 |
| -from app.translator.core.exceptions.core import StrictPlatformException, UnsupportedMappingsException |
| 6 | +from app.translator.core.exceptions.core import ( |
| 7 | + StrictPlatformException, |
| 8 | + UnsupportedMappingsException, |
| 9 | + UnsupportedPlatformAlternativeMapping, |
| 10 | +) |
7 | 11 | from app.translator.core.models.platform_details import PlatformDetails
|
8 | 12 | from app.translator.mappings.utils.load_from_files import LoaderFileMappings
|
9 | 13 |
|
@@ -205,7 +209,9 @@ def get_source_mapping(self, source_id: str) -> Optional[SourceMapping]:
|
205 | 209 | return self._source_mappings.get(source_id)
|
206 | 210 |
|
207 | 211 | def get_alternative_source_mapping(self, alt_config_name: str, source_id: str) -> Optional[SourceMapping]:
|
208 |
| - return self._alternative_mappings.get(alt_config_name, {}).get(source_id) |
| 212 | + if self._alternative_mappings.get(alt_config_name): |
| 213 | + return self._alternative_mappings.get(alt_config_name).get(source_id) |
| 214 | + raise UnsupportedPlatformAlternativeMapping(platform=self.details.platform_id, alt_mapping=alt_config_name) |
209 | 215 |
|
210 | 216 | def get_source_mappings_by_ids(
|
211 | 217 | self, source_mapping_ids: list[str], return_default: bool = True
|
|
0 commit comments