Skip to content

Commit

Permalink
fix: error expection and rm load_contracts (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ninjagod1251 authored Sep 10, 2024
1 parent 4e6bdeb commit b4b3b27
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from enum import Enum
from pathlib import Path
from typing import Annotated
from ape_vyper.exceptions import VyperCompileError
from ape.managers.compiler import CompilerError

from ape import Project
from ethpm_types import PackageManifest
Expand Down Expand Up @@ -178,6 +178,7 @@ async def compile_project(project_root: Path, manifest: PackageManifest):
# Create a contracts directory
contracts_dir = project_root / "contracts"
contracts_dir.mkdir()

# add request contracts in temp directory
if manifest.sources:
for filename, source in manifest.sources.items():
Expand All @@ -187,16 +188,14 @@ async def compile_project(project_root: Path, manifest: PackageManifest):
path.write_text(source.fetch_content())
try:
project = Project(project_root)
project.load_contracts()
compiled_manifest = project.extract_manifest()
results[project_root.name] = compiled_manifest
tasks[project_root.name] = TaskStatus.SUCCESS
except VyperCompileError as e:
except CompilerError as e:
results[project_root.name] = [
f"{e['sourceLocation'].get('file', 'Unknown file')}\n{e['type']}: {e.get('formattedMessage', e['message'])}"
for e in e.base_err.error_dict
]

tasks[project_root.name] = TaskStatus.FAILED
except Exception as e:
results[project_root.name] = {e.__class__.__name__:str(e)}
Expand Down

0 comments on commit b4b3b27

Please sign in to comment.