trace formatting
This commit is contained in:
parent
8f81fae116
commit
c484a67914
|
@ -328,41 +328,48 @@ std::ostream& showErrorInfo(std::ostream &out, const ErrorInfo &einfo, bool show
|
||||||
}
|
}
|
||||||
|
|
||||||
// traces
|
// 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)
|
for (auto iter = einfo.traces.rbegin(); iter != einfo.traces.rend(); ++iter)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if (nl)
|
out << std::endl << prefix;
|
||||||
out << std::endl << prefix;
|
out << ANSI_BLUE << "trace: " << ANSI_NORMAL << iter->hint.str() << std::endl;
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
auto pos = *iter->pos;
|
auto pos = *iter->pos;
|
||||||
printAtPos(prefix, pos, out);
|
printAtPos(prefix, pos, out);
|
||||||
nl = true;
|
nl = true;
|
||||||
auto loc = getCodeLines(pos);
|
auto loc = getCodeLines(pos);
|
||||||
if (loc.has_value())
|
if (loc.has_value())
|
||||||
|
{
|
||||||
|
out << std::endl;
|
||||||
printCodeLines(out, prefix, pos, *loc);
|
printCodeLines(out, prefix, pos, *loc);
|
||||||
|
out << std::endl;
|
||||||
|
}
|
||||||
} catch(const std::bad_optional_access& e) {
|
} catch(const std::bad_optional_access& e) {
|
||||||
out << iter->hint.str() << std::endl;
|
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::regex attrPathRegex(fmt(R"(%1%(\.%1%)*)", attrRegex));
|
||||||
|
|
||||||
static std::vector<std::shared_ptr<Installable>> parseInstallables(
|
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;
|
std::vector<std::shared_ptr<Installable>> result;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue