Skip to content

Commit 2fc681e

Browse files
committed
changed exceptions
1 parent 28dc4b3 commit 2fc681e

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

pystac/extensions/mlm.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ def bands(self) -> list[ModelBand] | list[str]:
912912
elif isinstance(bands, list) and all(isinstance(item, dict) for item in bands):
913913
return [ModelBand(band) for band in bands if isinstance(band, dict)]
914914

915-
raise STACError("Invalid bands property. Must list[str] or list[ModelBand]")
915+
raise TypeError("Invalid bands property. Must list[str] or list[ModelBand]")
916916

917917
@bands.setter
918918
def bands(self, v: list[ModelBand] | list[str]) -> None:
@@ -1454,7 +1454,7 @@ def ext(cls, obj: T, add_if_missing: bool = False) -> MLMExtension[T]:
14541454
MLMExtension[T]: The extended object
14551455
14561456
Raises:
1457-
pystac.STACError: When a :class:`pystac.Asset` object is apssed as the
1457+
pystac.TypeError: When a :class:`pystac.Asset` object is apssed as the
14581458
`obj` parameter
14591459
pystac.ExtensionTypeError: When any unsupported object is passed as the
14601460
`obj` parameter. If you see this extension in this context, please
@@ -1470,7 +1470,7 @@ def ext(cls, obj: T, add_if_missing: bool = False) -> MLMExtension[T]:
14701470
cls.ensure_owner_has_extension(obj, add_if_missing)
14711471
return cast(MLMExtension[T], ItemAssetMLMExtension(obj))
14721472
elif isinstance(obj, pystac.Asset):
1473-
raise pystac.STACError(
1473+
raise TypeError(
14741474
"This class cannot be used to extend STAC objects of type Assets. "
14751475
"To extend Asset objects, use either AssetGeneralMLMExtension or "
14761476
"AssetDetailedMLMExtension"
@@ -1739,7 +1739,7 @@ def __init__(self, asset: pystac.Asset):
17391739
@classmethod
17401740
def _ext(cls: type[AssetExtensionType], obj: pystac.Asset) -> AssetExtensionType:
17411741
if not isinstance(obj, pystac.Asset):
1742-
raise STACError(
1742+
raise TypeError(
17431743
"This class can only be used to extend Assets. "
17441744
"For Items and Collections use MLMExtension."
17451745
)

tests/extensions/test_mlm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1054,5 +1054,5 @@ def test_raise_exception_on_mlm_extension_and_asset() -> None:
10541054
media_type="application/tiff",
10551055
roles=["mlm:model"],
10561056
)
1057-
with pytest.raises(pystac.errors.STACError):
1057+
with pytest.raises(TypeError):
10581058
MLMExtension.ext(asset, add_if_missing=False)

0 commit comments

Comments
 (0)