diff options
author | regnat <rg@regnat.ovh> | 2022-03-03 10:50:35 +0100 |
---|---|---|
committer | regnat <rg@regnat.ovh> | 2022-03-07 10:09:09 +0100 |
commit | c0792b1546ceed1c02a02ca1286ead55f79d5798 (patch) | |
tree | b03b57763994b13ea800eb1c88f96d2a2dcfae14 /src/libutil/error.cc | |
parent | b09baf690bb00125805a02e0feae9636b2114599 (diff) |
Implement a suggestions mechanism
Each `Error` class now includes a set of suggestions, and these are printed by
the top-level handler.
Diffstat (limited to 'src/libutil/error.cc')
-rw-r--r-- | src/libutil/error.cc | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/libutil/error.cc b/src/libutil/error.cc index dcd2f82a5..15ae7a759 100644 --- a/src/libutil/error.cc +++ b/src/libutil/error.cc @@ -282,6 +282,13 @@ std::ostream & showErrorInfo(std::ostream & out, const ErrorInfo & einfo, bool s } } + auto suggestions = einfo.suggestions.trim(); + if (! suggestions.suggestions.empty()){ + oss << "Did you mean " << + suggestions.trim().pretty_print() << + "?" << std::endl; + } + // traces if (showTrace && !einfo.traces.empty()) { for (auto iter = einfo.traces.rbegin(); iter != einfo.traces.rend(); ++iter) { |