forked from lix-project/lix
comments and cleanup
This commit is contained in:
parent
958e81987b
commit
536bbf53e1
|
@ -10,27 +10,27 @@ MakeError(DemoError, Error);
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
makeDefaultLogger();
|
|
||||||
|
|
||||||
verbosity = lvlVomit;
|
verbosity = lvlVomit;
|
||||||
|
|
||||||
// In each program where errors occur, this has to be set.
|
// In each program where errors occur, this has to be set.
|
||||||
ErrorInfo::programName = std::optional("error-demo");
|
ErrorInfo::programName = std::optional("error-demo");
|
||||||
|
|
||||||
|
// 'DemoError' appears as error name.
|
||||||
try {
|
try {
|
||||||
throw DemoError("demo error was thrown");
|
throw DemoError("demo error was thrown");
|
||||||
} catch (Error &e) {
|
} catch (Error &e) {
|
||||||
logger->logEI(e.info());
|
logger->logEI(e.info());
|
||||||
}
|
}
|
||||||
|
|
||||||
// ErrorInfo constructor
|
// appending to the hint from the previous error
|
||||||
try {
|
try {
|
||||||
auto e = Error("some error");
|
auto e = Error("initial error");
|
||||||
throw DemoError(e.info());
|
throw DemoError(e.info());
|
||||||
} catch (Error &e) {
|
} catch (Error &e) {
|
||||||
ErrorInfo ei = e.info();
|
ErrorInfo ei = e.info();
|
||||||
string prevhint = (e.info().hint.has_value() ? e.info().hint->str() : "");
|
// using normaltxt to avoid the default yellow highlighting.
|
||||||
ei.hint = std::optional(hintfmt("previous hint was: %s", normaltxt(prevhint)));
|
ei.hint = hintfmt("%s; subsequent error message.",
|
||||||
|
normaltxt(e.info().hint ? e.info().hint->str() : ""));
|
||||||
logger->logEI(ei);
|
logger->logEI(ei);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,8 +38,8 @@ int main()
|
||||||
try {
|
try {
|
||||||
auto x = readFile(-1);
|
auto x = readFile(-1);
|
||||||
}
|
}
|
||||||
catch (Error &e) {
|
catch (SysError &e) {
|
||||||
std::cout << "error: " << e.sname() << std::endl;
|
std::cout << "errno was: " << e.errNo << std::endl;
|
||||||
logError(e.info());
|
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.
|
// But this is maybe a heavy format for those.
|
||||||
logger->logEI(
|
logger->logEI(
|
||||||
ErrorInfo { .level = lvlInfo,
|
ErrorInfo { .level = lvlInfo,
|
||||||
|
|
Loading…
Reference in a new issue