|
38 | 38 | ASSETS_DIR, |
39 | 39 | Package, |
40 | 40 | ) |
| 41 | +from ethpm.exceptions import ( |
| 42 | + ManifestValidationError, |
| 43 | + PyEthPMException, |
| 44 | +) |
41 | 45 | from ethpm.uri import ( |
42 | 46 | is_supported_content_addressed_uri, |
43 | 47 | resolve_uri_contents, |
|
56 | 60 | ) |
57 | 61 | from web3.exceptions import ( |
58 | 62 | InvalidAddress, |
59 | | - ManifestValidationError, |
60 | 63 | NameNotFound, |
61 | | - PMError, |
62 | 64 | ) |
63 | 65 | from web3.module import ( |
64 | 66 | Module, |
@@ -360,11 +362,13 @@ def get_local_package(self, package_name: str, ethpm_dir: Path = None) -> Packag |
360 | 362 | ethpm_dir = Path.cwd() / "_ethpm_packages" |
361 | 363 |
|
362 | 364 | if not ethpm_dir.name == "_ethpm_packages" or not ethpm_dir.is_dir(): |
363 | | - raise PMError(f"{ethpm_dir} is not a valid ethPM packages directory.") |
| 365 | + raise PyEthPMException( |
| 366 | + f"{ethpm_dir} is not a valid ethPM packages directory." |
| 367 | + ) |
364 | 368 |
|
365 | 369 | local_packages = [pkg.name for pkg in ethpm_dir.iterdir() if pkg.is_dir()] |
366 | 370 | if package_name not in local_packages: |
367 | | - raise PMError( |
| 371 | + raise PyEthPMException( |
368 | 372 | f"Package: {package_name} not found in {ethpm_dir}. " |
369 | 373 | f"Available packages include: {local_packages}." |
370 | 374 | ) |
@@ -402,7 +406,7 @@ def set_registry(self, address: Union[Address, ChecksumAddress, ENS]) -> None: |
402 | 406 | ) |
403 | 407 | self.registry = SimpleRegistry(addr_lookup, self.w3) |
404 | 408 | else: |
405 | | - raise PMError( |
| 409 | + raise PyEthPMException( |
406 | 410 | "Expected a canonical/checksummed address or ENS name for the address, " |
407 | 411 | f"instead received {type(address)}." |
408 | 412 | ) |
@@ -555,14 +559,14 @@ def _validate_set_registry(self) -> None: |
555 | 559 | try: |
556 | 560 | self.registry |
557 | 561 | except AttributeError: |
558 | | - raise PMError( |
| 562 | + raise PyEthPMException( |
559 | 563 | "web3.pm does not have a set registry. " |
560 | 564 | "Please set registry with either: " |
561 | 565 | "web3.pm.set_registry(address) or " |
562 | 566 | "web3.pm.deploy_and_set_registry()" |
563 | 567 | ) |
564 | 568 | if not isinstance(self.registry, ERC1319Registry): |
565 | | - raise PMError( |
| 569 | + raise PyEthPMException( |
566 | 570 | "web3.pm requires an instance of a subclass of ERC1319Registry " |
567 | 571 | "to be set as the web3.pm.registry attribute. Instead found: " |
568 | 572 | f"{type(self.registry)}." |
|
0 commit comments