2020-03-23 21:29:49 +00:00
|
|
|
#include "error.hh"
|
|
|
|
|
|
|
|
#include <optional>
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
using std::optional;
|
2020-03-24 17:21:35 +00:00
|
|
|
using std::nullopt;
|
2020-03-25 16:52:03 +00:00
|
|
|
using std::cout;
|
|
|
|
using std::endl;
|
2020-03-23 21:29:49 +00:00
|
|
|
|
2020-03-27 16:03:02 +00:00
|
|
|
int main()
|
|
|
|
{
|
|
|
|
using namespace nix;
|
2020-03-23 21:29:49 +00:00
|
|
|
|
2020-03-25 16:52:03 +00:00
|
|
|
ErrorInfo::programName = optional("errorTest");
|
|
|
|
|
2020-03-24 17:21:35 +00:00
|
|
|
/*
|
2020-03-23 21:29:49 +00:00
|
|
|
ColumnRange columnRange;
|
|
|
|
columnRange.start = 24;
|
|
|
|
columnRange.len = 14;
|
|
|
|
|
|
|
|
ErrLine errline;
|
|
|
|
errline.lineNumber = 7;
|
|
|
|
errline.columnRange = optional(columnRange);
|
|
|
|
errline.errLineOfCode = "line of code where the error occurred";
|
|
|
|
|
|
|
|
NixCode nixcode;
|
|
|
|
nixcode.nixFile = optional("myfile.nix");
|
|
|
|
nixcode.errLine = errline;
|
|
|
|
|
|
|
|
ErrorInfo generic;
|
|
|
|
generic.level = elError;
|
2020-03-24 15:18:23 +00:00
|
|
|
generic.name = "error name";
|
2020-03-23 21:29:49 +00:00
|
|
|
generic.description = "general error description";
|
2020-03-24 15:18:23 +00:00
|
|
|
generic.program = "nixtool.exe";
|
2020-03-23 21:29:49 +00:00
|
|
|
generic.nixCode = nixcode;
|
|
|
|
|
2020-03-27 16:03:02 +00:00
|
|
|
printErrorInfo(generic);
|
2020-03-24 17:21:35 +00:00
|
|
|
*/
|
2020-03-24 15:18:23 +00:00
|
|
|
|
2020-03-27 16:03:02 +00:00
|
|
|
printErrorInfo(StandardError()
|
2020-03-24 17:21:35 +00:00
|
|
|
.name("name")
|
2020-03-27 16:03:02 +00:00
|
|
|
.description("description")
|
|
|
|
.nohint()
|
|
|
|
);
|
2020-03-24 17:21:35 +00:00
|
|
|
|
2020-03-27 16:03:02 +00:00
|
|
|
printErrorInfo(StandardWarning()
|
2020-03-24 17:21:35 +00:00
|
|
|
.name("warning name")
|
2020-03-27 16:03:02 +00:00
|
|
|
.description("warning description")
|
|
|
|
.nohint()
|
|
|
|
);
|
2020-03-24 17:21:35 +00:00
|
|
|
|
|
|
|
|
2020-03-27 16:03:02 +00:00
|
|
|
printErrorInfo(MkNixWarning()
|
2020-03-24 20:24:57 +00:00
|
|
|
.name("warning name")
|
|
|
|
.description("warning description")
|
|
|
|
.nixFile("myfile.nix")
|
|
|
|
.lineNumber(40)
|
|
|
|
.columnRange(13,7)
|
|
|
|
.linesOfCode(nullopt
|
|
|
|
,"this is the problem line of code"
|
|
|
|
,nullopt));
|
|
|
|
|
2020-03-27 16:03:02 +00:00
|
|
|
printErrorInfo(MkNixError()
|
2020-03-24 20:24:57 +00:00
|
|
|
.name("error name")
|
2020-03-25 17:20:44 +00:00
|
|
|
.description("error description")
|
2020-03-24 20:24:57 +00:00
|
|
|
.nixFile("myfile.nix")
|
|
|
|
.lineNumber(40)
|
|
|
|
.columnRange(13,7)
|
2020-03-27 16:03:02 +00:00
|
|
|
.linesOfCode(optional("previous line of code")
|
2020-03-24 20:24:57 +00:00
|
|
|
,"this is the problem line of code"
|
2020-03-27 16:03:02 +00:00
|
|
|
,optional("next line of code"))
|
|
|
|
.hint(hintfmt("this hint has %1% templated %2%!!") % "yellow" % "values")
|
|
|
|
);
|
2020-03-24 15:18:23 +00:00
|
|
|
|
2020-03-23 21:29:49 +00:00
|
|
|
return 0;
|
|
|
|
}
|