Skip to content

Commit

Permalink
Merge branch 'mr/bortolussi/improve_error_repporting_when_loading_spe…
Browse files Browse the repository at this point in the history
…cs' into 'master'

Improve error reporting when loading specs

See merge request it/e3-core!38
  • Loading branch information
JulienBortolussiAda committed Sep 3, 2024
2 parents 86e2aeb + 66d65cd commit 20f10cb
Showing 1 changed file with 43 additions and 20 deletions.
63 changes: 43 additions & 20 deletions src/e3/anod/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,14 +460,26 @@ def add_dep(spec_instance: Anod, dep: Dependency, dep_instance: Anod) -> None:
spec_instance.deps[dep.local_name] = dep_instance

# Initialize a spec instance
spec = self.load(
name,
qualifier=qualifier,
env=env,
kind=primitive,
sandbox=sandbox,
source_name=source_name,
)
try:
spec = self.load(
name,
qualifier=qualifier,
env=env,
kind=primitive,
sandbox=sandbox,
source_name=source_name,
)
except AnodError as err:
err.messages[-1] = "\n".join(
[
err.messages[-1],
"",
"Anod traceback:",
(f"raised from {primitive}(name={name}, " f"qual={qualifier})"),
]
)
raise err

result: Build | CreateSources | CreateSource | Install | Test

# Initialize the resulting action based on the primitive name
Expand Down Expand Up @@ -691,18 +703,29 @@ def add_dep(spec_instance: Anod, dep: Dependency, dep_instance: Anod) -> None:
)

continue

child_action = self.add_spec(
name=e.name,
env=e.env(spec, self.default_env),
primitive=e.kind if e.kind != "download" else "install",
qualifier=e.parsed_qualifier,
plan_args=None,
plan_line=plan_line,
sandbox=sandbox,
upload=upload,
force_download=e.kind == "download",
)
try:
child_action = self.add_spec(
name=e.name,
env=e.env(spec, self.default_env),
primitive=e.kind if e.kind != "download" else "install",
qualifier=e.parsed_qualifier,
plan_args=None,
plan_line=plan_line,
sandbox=sandbox,
upload=upload,
force_download=e.kind == "download",
)
except AnodError as err:
err.messages[-1] = "\n".join(
[
err.messages[-1],
(
f"requested from {spec.kind}(name={spec.name}, "
f"qual={spec.parsed_qualifier})"
),
]
)
raise err

add_dep(
spec_instance=spec, dep=e, dep_instance=child_action.anod_instance
Expand Down

0 comments on commit 20f10cb

Please sign in to comment.