1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-11 21:16:02 +01:00

refact: TraceKind -> TracePrint

Co-authored-by: Rebecca Turner <rbt@sent.as>
This commit is contained in:
Robert Hensing 2024-03-27 16:27:06 +01:00
parent bed541b04e
commit d4fa0a84a5
3 changed files with 16 additions and 10 deletions

View file

@ -61,16 +61,22 @@ void printCodeLines(std::ostream & out,
const Pos & errPos,
const LinesOfCode & loc);
enum struct TraceKind {
Other,
/** Produced by builtins.addErrorContext. Always printed. */
Custom,
/**
* When a stack frame is printed.
*/
enum struct TracePrint {
/**
* The default behavior; always printed when `--show-trace` is set.
*/
Default,
/** Always printed. Produced by `builtins.addErrorContext`. */
Always,
};
struct Trace {
std::shared_ptr<Pos> pos;
HintFmt hint;
TraceKind kind = TraceKind::Other;
TracePrint print = TracePrint::Default;
};
inline bool operator<(const Trace& lhs, const Trace& rhs);
@ -168,7 +174,7 @@ public:
addTrace(std::move(e), HintFmt(std::string(fs), args...));
}
void addTrace(std::shared_ptr<Pos> && e, HintFmt hint, TraceKind kind = TraceKind::Other);
void addTrace(std::shared_ptr<Pos> && e, HintFmt hint, TracePrint print = TracePrint::Default);
bool hasTrace() const { return !err.traces.empty(); }