1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-26 20:01:15 +02:00

Error classname as name

This commit is contained in:
Ben Burdette 2020-04-28 21:06:08 -06:00
parent e51a757720
commit 22e6490311
5 changed files with 55 additions and 41 deletions

View file

@ -4,10 +4,12 @@
#include <iostream>
#include <optional>
using namespace nix;
MakeError(DemoError, Error);
int main()
{
using namespace nix;
makeDefaultLogger();
verbosity = lvlVomit;
@ -15,6 +17,12 @@ int main()
// In each program where errors occur, this has to be set.
ErrorInfo::programName = std::optional("error-demo");
try {
throw DemoError("demo error was thrown");
} catch (Error &e) {
logger->logEI(e.info());
}
// For completeness sake, info through vomit levels.
// But this is maybe a heavy format for those.
logger->logEI(
@ -79,7 +87,7 @@ int main()
.prevLineOfCode = std::nullopt,
.errLineOfCode = "this is the problem line of code",
.nextLineOfCode = std::nullopt
}});
}});
// Error with previous and next lines of code.
logError(
@ -93,7 +101,7 @@ int main()
.prevLineOfCode = std::optional("previous line of code"),
.errLineOfCode = "this is the problem line of code",
.nextLineOfCode = std::optional("next line of code"),
}});
}});
return 0;