diff options
author | Ben Burdette <bburdette@gmail.com> | 2020-05-11 13:58:38 -0600 |
---|---|---|
committer | Ben Burdette <bburdette@gmail.com> | 2020-05-11 13:58:38 -0600 |
commit | 536bbf53e12c80f52c2679aec734d895b0058f5b (patch) | |
tree | b028f9313ae34b0d62b04305cd6121e2fe75b731 | |
parent | 958e81987b5b86fba06090078a556f51037aa23c (diff) |
comments and cleanup
-rw-r--r-- | src/error-demo/error-demo.cc | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/error-demo/error-demo.cc b/src/error-demo/error-demo.cc index 41293427c..8f484431c 100644 --- a/src/error-demo/error-demo.cc +++ b/src/error-demo/error-demo.cc @@ -10,27 +10,27 @@ MakeError(DemoError, Error); int main() { - makeDefaultLogger(); - verbosity = lvlVomit; // In each program where errors occur, this has to be set. ErrorInfo::programName = std::optional("error-demo"); + // 'DemoError' appears as error name. try { throw DemoError("demo error was thrown"); } catch (Error &e) { logger->logEI(e.info()); } - // ErrorInfo constructor + // appending to the hint from the previous error try { - auto e = Error("some error"); + auto e = Error("initial error"); throw DemoError(e.info()); } catch (Error &e) { ErrorInfo ei = e.info(); - string prevhint = (e.info().hint.has_value() ? e.info().hint->str() : ""); - ei.hint = std::optional(hintfmt("previous hint was: %s", normaltxt(prevhint))); + // using normaltxt to avoid the default yellow highlighting. + ei.hint = hintfmt("%s; subsequent error message.", + normaltxt(e.info().hint ? e.info().hint->str() : "")); logger->logEI(ei); } @@ -38,8 +38,8 @@ int main() try { auto x = readFile(-1); } - catch (Error &e) { - std::cout << "error: " << e.sname() << std::endl; + catch (SysError &e) { + std::cout << "errno was: " << e.errNo << std::endl; logError(e.info()); } @@ -59,7 +59,7 @@ int main() } } - // For completeness sake, info through vomit levels. + // For completeness sake, show 'info' through 'vomit' levels. // But this is maybe a heavy format for those. logger->logEI( ErrorInfo { .level = lvlInfo, |