mirror of
https://github.com/NixOS/nix
synced 2025-06-25 14:51:16 +02:00
Implement a suggestions mechanism
Each `Error` class now includes a set of suggestions, and these are printed by the top-level handler.
This commit is contained in:
parent
b09baf690b
commit
c0792b1546
7 changed files with 191 additions and 6 deletions
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include "suggestions.hh"
|
||||
#include "ref.hh"
|
||||
#include "types.hh"
|
||||
#include "fmt.hh"
|
||||
|
@ -112,6 +113,8 @@ struct ErrorInfo {
|
|||
std::optional<ErrPos> errPos;
|
||||
std::list<Trace> traces;
|
||||
|
||||
Suggestions suggestions;
|
||||
|
||||
static std::optional<std::string> programName;
|
||||
};
|
||||
|
||||
|
@ -141,6 +144,11 @@ public:
|
|||
: err { .level = lvlError, .msg = hintfmt(fs, args...) }
|
||||
{ }
|
||||
|
||||
template<typename... Args>
|
||||
BaseError(const Suggestions & sug, const Args & ... args)
|
||||
: err { .level = lvlError, .msg = hintfmt(args...), .suggestions = sug }
|
||||
{ }
|
||||
|
||||
BaseError(hintformat hint)
|
||||
: err { .level = lvlError, .msg = hint }
|
||||
{ }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue