aboutsummaryrefslogtreecommitdiff
path: root/src/error-demo
diff options
context:
space:
mode:
authorBen Burdette <bburdette@gmail.com>2020-04-28 21:06:08 -0600
committerBen Burdette <bburdette@gmail.com>2020-04-28 21:06:08 -0600
commit22e6490311015e076a09d5608834bd0dec1d7020 (patch)
tree5aff3f1fcadac73e929c9dd13599c92dc000b487 /src/error-demo
parente51a757720ade58e48128730134400cf12f54851 (diff)
Error classname as name
Diffstat (limited to 'src/error-demo')
-rw-r--r--src/error-demo/error-demo.cc16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/error-demo/error-demo.cc b/src/error-demo/error-demo.cc
index 14027278d..98018ca0e 100644
--- a/src/error-demo/error-demo.cc
+++ b/src/error-demo/error-demo.cc
@@ -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;