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:
parent
e51a757720
commit
22e6490311
5 changed files with 55 additions and 41 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue