Skip to content

Commit

Permalink
Raise exception when compiler version is not supported by solc-select
Browse files Browse the repository at this point in the history
  • Loading branch information
0xalpharush committed Mar 14, 2022
1 parent 2279686 commit 136a0ce
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions crytic_compile/compiler/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

LOGGER = logging.getLogger("CryticCompile")


class UnsupportedSolcVersion(Exception):
"""The requested solc version cannot be installed by solc-select."""


# pylint: disable=too-few-public-methods
class CompilerVersion:
"""
Expand Down Expand Up @@ -37,16 +42,21 @@ def look_for_installed_version(self) -> None:
This function queries solc-select to see if the current compiler version is installed
And if its not it will install it
Returns:
Raises:
UnsupportedSolcVersion: If the version requested cannot be automatically installed by solc-select.
"""

# pylint: disable=import-outside-toplevel
try:
from solc_select import solc_select

if self.version not in solc_select.installed_versions():
if (
self.version not in solc_select.installed_versions()
and self.version in solc_select.get_available_versions()
):
solc_select.install_artifacts([self.version])
else:
raise UnsupportedSolcVersion(f"{self.version} is not supported by solc-select")

except ImportError:
LOGGER.info(
Expand Down

0 comments on commit 136a0ce

Please sign in to comment.