mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 05:56:15 +02:00
trace formatting
This commit is contained in:
parent
8f81fae116
commit
c484a67914
2 changed files with 33 additions and 26 deletions
|
@ -328,41 +328,48 @@ std::ostream& showErrorInfo(std::ostream &out, const ErrorInfo &einfo, bool show
|
|||
}
|
||||
|
||||
// traces
|
||||
if (showTrace) {
|
||||
if (showTrace && !einfo.traces.empty())
|
||||
{
|
||||
const string tracetitle(" show-trace output ");
|
||||
|
||||
int fill = errwidth - tracetitle.length();
|
||||
int lw = 0;
|
||||
int rw = 0;
|
||||
const int min_dashes = 3;
|
||||
if (fill > min_dashes * 2) {
|
||||
if (fill % 2 != 0) {
|
||||
lw = fill / 2;
|
||||
rw = lw + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
lw = rw = fill / 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
lw = rw = min_dashes;
|
||||
|
||||
if (nl)
|
||||
out << std::endl << prefix;
|
||||
|
||||
out << ANSI_BLUE << std::string(lw, '-') << tracetitle << std::string(rw, '-') << ANSI_NORMAL;
|
||||
|
||||
for (auto iter = einfo.traces.rbegin(); iter != einfo.traces.rend(); ++iter)
|
||||
{
|
||||
try {
|
||||
if (nl)
|
||||
out << std::endl << prefix;
|
||||
|
||||
const string tracetitle(" show-trace output ");
|
||||
|
||||
int fill = errwidth - tracetitle.length();
|
||||
int lw = 0;
|
||||
int rw = 0;
|
||||
const int min_dashes = 3;
|
||||
if (fill > min_dashes * 2) {
|
||||
if (fill % 2 != 0) {
|
||||
lw = fill / 2;
|
||||
rw = lw + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
lw = rw = fill / 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
lw = rw = min_dashes;
|
||||
|
||||
out << ANSI_BLUE << std::string(lw, '-') << tracetitle << std::string(rw, '-') << std::endl << prefix;
|
||||
out << iter->hint.str() << std::endl;
|
||||
out << std::endl << prefix;
|
||||
out << ANSI_BLUE << "trace: " << ANSI_NORMAL << iter->hint.str() << std::endl;
|
||||
|
||||
auto pos = *iter->pos;
|
||||
printAtPos(prefix, pos, out);
|
||||
nl = true;
|
||||
auto loc = getCodeLines(pos);
|
||||
if (loc.has_value())
|
||||
{
|
||||
out << std::endl;
|
||||
printCodeLines(out, prefix, pos, *loc);
|
||||
out << std::endl;
|
||||
}
|
||||
} catch(const std::bad_optional_access& e) {
|
||||
out << iter->hint.str() << std::endl;
|
||||
}
|
||||
|
|
|
@ -212,7 +212,7 @@ std::string attrRegex = R"([A-Za-z_][A-Za-z0-9-_+]*)";
|
|||
static std::regex attrPathRegex(fmt(R"(%1%(\.%1%)*)", attrRegex));
|
||||
|
||||
static std::vector<std::shared_ptr<Installable>> parseInstallables(
|
||||
SourceExprCommand & cmd, ref<Store> store, std::vetor<std::string> ss, bool useDefaultInstallables)
|
||||
SourceExprCommand & cmd, ref<Store> store, std::vector<std::string> ss, bool useDefaultInstallables)
|
||||
{
|
||||
std::vector<std::shared_ptr<Installable>> result;
|
||||
|
||||
|
|
Loading…
Reference in a new issue