forked from lix-project/lix
pretending to be const
This commit is contained in:
parent
e3901638b5
commit
1b801cec40
|
@ -43,6 +43,22 @@ int main()
|
|||
logError(e.info());
|
||||
}
|
||||
|
||||
// current exception
|
||||
try {
|
||||
throw DemoError("DemoError handled as a %1%", "std::exception");
|
||||
}
|
||||
catch (...) {
|
||||
const std::exception_ptr &eptr = std::current_exception();
|
||||
try
|
||||
{
|
||||
std::rethrow_exception(eptr);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
std::cerr << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
// For completeness sake, info through vomit levels.
|
||||
// But this is maybe a heavy format for those.
|
||||
logger->logEI(
|
||||
|
|
|
@ -82,10 +82,10 @@ class BaseError : public std::exception
|
|||
{
|
||||
protected:
|
||||
string prefix_; // used for location traces etc.
|
||||
ErrorInfo err;
|
||||
mutable ErrorInfo err;
|
||||
|
||||
std::optional<string> what_;
|
||||
const string& calcWhat()
|
||||
mutable std::optional<string> what_;
|
||||
const string& calcWhat() const
|
||||
{
|
||||
if (what_.has_value())
|
||||
return *what_;
|
||||
|
@ -131,12 +131,12 @@ public:
|
|||
|
||||
#ifdef EXCEPTION_NEEDS_THROW_SPEC
|
||||
~BaseError() throw () { };
|
||||
const char * what() throw () { return calcWhat().c_str(); }
|
||||
const char * what() const throw () { return calcWhat().c_str(); }
|
||||
#else
|
||||
const char * what() noexcept { return calcWhat().c_str(); }
|
||||
const char * what() const noexcept override { return calcWhat().c_str(); }
|
||||
#endif
|
||||
|
||||
const string & msg() { return calcWhat(); }
|
||||
const string & msg() const { return calcWhat(); }
|
||||
const string & prefix() const { return prefix_; }
|
||||
BaseError & addPrefix(const FormatOrString & fs);
|
||||
|
||||
|
|
|
@ -368,7 +368,7 @@ static void _main(int argc, char * * argv)
|
|||
shell = drv->queryOutPath() + "/bin/bash";
|
||||
|
||||
} catch (Error & e) {
|
||||
// TODO: append error msg
|
||||
// TODO: append error msg; warn()?
|
||||
logError(e.info());
|
||||
printError("warning: %s; will use bash from your environment", e.what());
|
||||
shell = "bash";
|
||||
|
|
Loading…
Reference in a new issue