From 0fc035dd4d51c70231a46d6b8a6ba18a91e8ae43 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 26 Oct 2023 11:36:19 +0200 Subject: Minor diagnostics improvement --- libbuild2/adhoc-rule-regex-pattern.cxx | 4 +++- libbuild2/parser.cxx | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/libbuild2/adhoc-rule-regex-pattern.cxx b/libbuild2/adhoc-rule-regex-pattern.cxx index 257952f..c221bef 100644 --- a/libbuild2/adhoc-rule-regex-pattern.cxx +++ b/libbuild2/adhoc-rule-regex-pattern.cxx @@ -86,7 +86,9 @@ namespace build2 tt = n.untyped () ? &file::static_type : s.find_target_type (n.type); if (tt == nullptr) - fail (loc) << "unknown target type " << n.type; + fail (loc) << "unknown target type " << n.type << + info << "perhaps the module that defines this target type is " + << "not loaded by project " << *s.root_scope (); } bool e (n.pattern && diff --git a/libbuild2/parser.cxx b/libbuild2/parser.cxx index 9ced841..55c5c6c 100644 --- a/libbuild2/parser.cxx +++ b/libbuild2/parser.cxx @@ -931,7 +931,9 @@ namespace build2 : scope_->find_target_type (n.type)); if (ttype == nullptr) - fail (nloc) << "unknown target type " << n.type; + fail (nloc) << "unknown target type " << n.type << + info << "perhaps the module that defines this target type is " + << "not loaded by project " << *scope_->root_scope (); f (t, tt, nullopt, n.pattern, ttype, move (n.value), nloc); }; @@ -1359,7 +1361,9 @@ namespace build2 : scope_->find_target_type (n.type); if (ttype == nullptr) - fail (nloc) << "unknown target type " << n.type; + fail (nloc) << "unknown target type " << n.type << + info << "perhaps the module that defines this target type is " + << "not loaded by project " << *scope_->root_scope (); if (!gns.empty ()) { @@ -2773,7 +2777,9 @@ namespace build2 optional& e (rp.second); if (t == nullptr) - fail (ploc) << "unknown target type " << n.type; + fail (ploc) << "unknown target type " << n.type << + info << "perhaps the module that defines this target type is " + << "not loaded by project " << *scope_->root_scope (); if (t->factory == nullptr) fail (ploc) << "abstract target type " << t->name << "{}"; @@ -4339,7 +4345,9 @@ namespace build2 const target_type* bt (scope_->find_target_type (bn)); if (bt == nullptr) - fail (t) << "unknown target type " << bn; + fail (t) << "unknown target type " << bn << + info << "perhaps the module that defines this target type is " + << "not loaded by project " << *scope_->root_scope (); // The derive_target_type() call below does not produce a non-abstract // type if passed an abstract base. So we ban this for now (it's unclear -- cgit v1.1