aboutsummaryrefslogtreecommitdiff
path: root/src/error-demo/error-demo.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-06-17 10:26:52 +0200
committerEelco Dolstra <edolstra@gmail.com>2020-06-17 10:26:52 +0200
commit1524752c17ee8753467f068c23fbe1d994aa8f75 (patch)
treec802ca482e2461765dcbdcef5cc6fa38c9d1c42b /src/error-demo/error-demo.cc
parent7db879e65e83b1c65206b490d36a69e97c5a877a (diff)
parent29542865cee37ab22efe1bd142900b69f6c59f0d (diff)
Merge remote-tracking branch 'origin/master' into flakes
Diffstat (limited to 'src/error-demo/error-demo.cc')
-rw-r--r--src/error-demo/error-demo.cc66
1 files changed, 0 insertions, 66 deletions
diff --git a/src/error-demo/error-demo.cc b/src/error-demo/error-demo.cc
deleted file mode 100644
index a9ff6057c..000000000
--- a/src/error-demo/error-demo.cc
+++ /dev/null
@@ -1,66 +0,0 @@
-#include "error.hh"
-#include "nixexpr.hh"
-
-#include <iostream>
-#include <optional>
-
-int main()
-{
- using namespace nix;
-
- // In each program where errors occur, this has to be set.
- ErrorInfo::programName = std::optional("error-demo");
-
- // Error in a program; no hint and no nix code.
- printErrorInfo(
- ErrorInfo { .level = elError,
- .name = "name",
- .description = "error description",
- });
-
- // Warning with name, description, and hint.
- // The hintfmt function makes all the substituted text yellow.
- printErrorInfo(
- ErrorInfo { .level = elWarning,
- .name = "name",
- .description = "error description",
- .hint = std::optional(
- hintfmt("there was a %1%", "warning")),
- });
-
-
- // Warning with nix file, line number, column, and the lines of
- // code where a warning occurred.
- SymbolTable testTable;
- auto problem_file = testTable.create("myfile.nix");
-
- printErrorInfo(
- ErrorInfo{
- .level = elWarning,
- .name = "warning name",
- .description = "warning description",
- .hint = hintfmt("this hint has %1% templated %2%!!", "yellow", "values"),
- .nixCode = NixCode {
- .errPos = Pos(problem_file, 40, 13),
- .prevLineOfCode = std::nullopt,
- .errLineOfCode = "this is the problem line of code",
- .nextLineOfCode = std::nullopt
- }});
-
- // Error with previous and next lines of code.
- printErrorInfo(
- ErrorInfo{
- .level = elError,
- .name = "error name",
- .description = "error description",
- .hint = hintfmt("this hint has %1% templated %2%!!", "yellow", "values"),
- .nixCode = NixCode {
- .errPos = Pos(problem_file, 40, 13),
- .prevLineOfCode = std::optional("previous line of code"),
- .errLineOfCode = "this is the problem line of code",
- .nextLineOfCode = std::optional("next line of code"),
- }});
-
-
- return 0;
-}