nix-super/tests/errors/main.cc

72 lines
1.6 KiB
C++
Raw Normal View History

2020-03-23 23:29:49 +02:00
#include "error.hh"
#include <optional>
#include <iostream>
using std::optional;
2020-03-24 19:21:35 +02:00
using std::nullopt;
2020-03-23 23:29:49 +02:00
int main() {
using namespace nix;
2020-03-24 19:21:35 +02:00
/*
2020-03-23 23:29:49 +02: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 17:18:23 +02:00
generic.name = "error name";
2020-03-23 23:29:49 +02:00
generic.description = "general error description";
2020-03-24 17:18:23 +02:00
generic.program = "nixtool.exe";
2020-03-23 23:29:49 +02:00
generic.nixCode = nixcode;
print_error(generic);
2020-03-24 19:21:35 +02:00
*/
2020-03-24 17:18:23 +02:00
print_error(StandardError()
2020-03-24 19:21:35 +02:00
.name("name")
.description("description"));
print_error(StandardWarning()
2020-03-24 19:21:35 +02:00
.name("warning name")
.description("warning description"));
print_error(MkNixWarning()
.name("warning name")
.description("warning description")
.nixFile("myfile.nix")
.lineNumber(40)
.columnRange(13,7)
.linesOfCode(nullopt
,"this is the problem line of code"
,nullopt));
print_error(MkNixError()
.name("error name")
.description("warning description")
.nixFile("myfile.nix")
.lineNumber(40)
.columnRange(13,7)
.linesOfCode(nullopt
,"this is the problem line of code"
,nullopt));
2020-03-24 17:18:23 +02:00
2020-03-23 23:29:49 +02:00
return 0;
}