mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-25 15:26:17 +02:00
refact: TraceKind -> TracePrint
Co-authored-by: Rebecca Turner <rbt@sent.as>
This commit is contained in:
parent
bed541b04e
commit
d4fa0a84a5
3 changed files with 16 additions and 10 deletions
|
@ -826,7 +826,7 @@ static void prim_addErrorContext(EvalState & state, const PosIdx pos, Value * *
|
|||
auto message = state.coerceToString(pos, *args[0], context,
|
||||
"while evaluating the error message passed to builtins.addErrorContext",
|
||||
false, false).toOwned();
|
||||
e.addTrace(nullptr, HintFmt(message), TraceKind::Custom);
|
||||
e.addTrace(nullptr, HintFmt(message), TracePrint::Always);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
|
||||
namespace nix {
|
||||
|
||||
void BaseError::addTrace(std::shared_ptr<Pos> && e, HintFmt hint, TraceKind kind)
|
||||
void BaseError::addTrace(std::shared_ptr<Pos> && e, HintFmt hint, TracePrint print)
|
||||
{
|
||||
err.traces.push_front(Trace { .pos = std::move(e), .hint = hint, .kind = kind });
|
||||
err.traces.push_front(Trace { .pos = std::move(e), .hint = hint, .print = print });
|
||||
}
|
||||
|
||||
void throwExceptionSelfCheck(){
|
||||
|
@ -388,7 +388,7 @@ std::ostream & showErrorInfo(std::ostream & out, const ErrorInfo & einfo, bool s
|
|||
truncate = true;
|
||||
}
|
||||
|
||||
if (!truncate || trace.kind == TraceKind::Custom) {
|
||||
if (!truncate || trace.print == TracePrint::Always) {
|
||||
|
||||
if (tracesSeen.count(trace)) {
|
||||
skippedTraces.push_back(trace);
|
||||
|
|
|
@ -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(); }
|
||||
|
||||
|
|
Loading…
Reference in a new issue