aboutsummaryrefslogtreecommitdiff
path: root/src/libutil
diff options
context:
space:
mode:
authorBen Burdette <bburdette@gmail.com>2020-03-23 15:29:49 -0600
committerBen Burdette <bburdette@gmail.com>2020-03-23 15:29:49 -0600
commitaadd59d005bdabbb801f622dc1a0e3b12a5e5286 (patch)
tree900c81739021c1fb725c4df23316fca918ebd634 /src/libutil
parentf694f43d7ddd270706e6e3a5f034336a5a83fb86 (diff)
error test
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/error.cc36
-rw-r--r--src/libutil/error.hh2
2 files changed, 25 insertions, 13 deletions
diff --git a/src/libutil/error.cc b/src/libutil/error.cc
index 4af4691d4..71f422622 100644
--- a/src/libutil/error.cc
+++ b/src/libutil/error.cc
@@ -8,7 +8,7 @@ using std::cout;
using std::endl;
// return basic_format?
-string showErrLine(ErrLine &errLine)
+string showErrLine(ErrLine &errLine)
{
if (errLine.columnRange.has_value())
{
@@ -22,15 +22,26 @@ string showErrLine(ErrLine &errLine)
void print_code_lines(string &prefix, NixCode &nix_code)
{
+
if (nix_code.errLine.has_value())
{
// previous line of code.
if (nix_code.errLine->prevLineOfCode.has_value()) {
- cout << format("%1% %2$+5d%| %3%") % prefix % (nix_code.errLine->lineNumber - 1) % *nix_code.errLine->prevLineOfCode;
+ cout << format("%1% %|2$5d|| %3%")
+ % prefix
+ % (nix_code.errLine->lineNumber - 1)
+ % *nix_code.errLine->prevLineOfCode
+ << endl;
}
- // line of code containing the error.
- cout << format("%1% %2$+5d%| %3%") % prefix % (nix_code.errLine->lineNumber) % nix_code.errLine->errLineOfCode;
+ // line of code containing the error.%2$+5d%
+ cout << format("%1% %|2$5d|| %3%")
+ % prefix
+ % (nix_code.errLine->lineNumber)
+ % nix_code.errLine->errLineOfCode
+ << endl;
+
+
// error arrows for the column range.
if (nix_code.errLine->columnRange.has_value())
@@ -49,19 +60,21 @@ void print_code_lines(string &prefix, NixCode &nix_code)
arrows.append("^");
}
- cout << format("%1% |%2%%3%") % prefix % spaces % arrows;
+ cout << format("%1% |%2%%3%") % prefix % spaces % arrows;
}
+
// next line of code.
if (nix_code.errLine->nextLineOfCode.has_value()) {
- cout << format("%1% %2$+5d%| %3%") % prefix % (nix_code.errLine->lineNumber + 1) % *nix_code.errLine->nextLineOfCode;
+ cout << format("%1% %|2$5d|| %3%")
+ % prefix
+ % (nix_code.errLine->lineNumber + 1)
+ % *nix_code.errLine->nextLineOfCode
+ << endl;
}
}
- else
- {
- }
}
@@ -99,7 +112,8 @@ void print_error(ErrorInfo &einfo)
% "---"
% einfo.errName
% dashes
- % einfo.toolName;
+ % einfo.toolName
+ << endl;
// filename.
if (einfo.nixCode.has_value())
@@ -110,7 +124,7 @@ void print_error(ErrorInfo &einfo)
? string(" ") + showErrLine(*einfo.nixCode->errLine)
: "";
- cout << format("%1%in file: %2%%3%") % prefix % *einfo.nixCode->nixFile % eline;
+ cout << format("%1%in file: %2%%3%") % prefix % *einfo.nixCode->nixFile % eline << endl;
cout << prefix << endl;
}
else
diff --git a/src/libutil/error.hh b/src/libutil/error.hh
index 0bc1f4e24..8dac1508e 100644
--- a/src/libutil/error.hh
+++ b/src/libutil/error.hh
@@ -3,11 +3,9 @@
#include "types.hh"
#include <string>
#include <optional>
-// #include <boost/format.hpp>
using std::string;
using std::optional;
-// using boost::format;
namespace nix {