feat(cli): three-way unresolved-namespace hint (#241 T3)
A project-namespaced (::) unknown type id now hints by tier: outside any project the existing "no Aura.toml was found" text stays byte-identical; inside a data-only project the hint names the missing node crate and the attach verb (aura nodes new); a loaded node crate gets no hint (the vocabulary error carries the message). refs #241
This commit is contained in:
@@ -376,18 +376,25 @@ fn gang_fault_prose(e: &CompileError) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
/// (#185) When an unresolved type id LOOKS project-namespaced (`::`) but no
|
||||
/// project was loaded for this invocation (`env.provenance()` is `None`),
|
||||
/// append a hint pointing at the missing `Aura.toml` — the likeliest cause is
|
||||
/// "ran outside the project directory", not "genuinely unknown std id". Bare
|
||||
/// std-vocabulary ids (no `::`) and invocations that DO have a project loaded
|
||||
/// get no hint.
|
||||
/// (#185/#241) When an unresolved type id LOOKS project-namespaced (`::`),
|
||||
/// the likeliest causes are environmental, tiered: outside any project the
|
||||
/// hint points at the missing `Aura.toml`; inside a data-only project it
|
||||
/// points at the missing node crate. Bare std ids (no `::`) and invocations
|
||||
/// with a loaded node crate get no hint (the vocabulary error carries the
|
||||
/// message).
|
||||
pub(crate) fn unresolved_namespace_hint(e: &LoadError, env: &crate::project::Env) -> Option<String> {
|
||||
match e {
|
||||
LoadError::UnknownNodeType(t) if t.contains("::") && env.provenance().is_none() => Some(
|
||||
"type id looks project-namespaced but no Aura.toml was found — run inside a project directory"
|
||||
.to_string(),
|
||||
),
|
||||
LoadError::UnknownNodeType(t) if t.contains("::") => match env.provenance() {
|
||||
None => Some(
|
||||
"type id looks project-namespaced but no Aura.toml was found — run inside a project directory"
|
||||
.to_string(),
|
||||
),
|
||||
Some(p) if p.namespace.is_none() => Some(
|
||||
"type id looks project-namespaced but this project binds no node crate — attach one with `aura nodes new <name>`"
|
||||
.to_string(),
|
||||
),
|
||||
Some(_) => None,
|
||||
},
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user