Merge pull request #4256 from zlobober/useful_what_in_exceptions

Make exception.what() less useless.
This commit is contained in:
alexey-milovidov 2019-02-07 12:15:43 +03:00 committed by GitHub
commit 7c830941a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 3 deletions

View File

@ -88,7 +88,7 @@ std::string getCurrentExceptionMessage(bool with_stacktrace, bool check_embedded
try
{
stream << "Poco::Exception. Code: " << ErrorCodes::POCO_EXCEPTION << ", e.code() = " << e.code()
<< ", e.displayText() = " << e.displayText() << ", e.what() = " << e.what();
<< ", e.displayText() = " << e.displayText();
}
catch (...) {}
}
@ -202,7 +202,7 @@ std::string getExceptionMessage(const Exception & e, bool with_stacktrace, bool
}
}
stream << "Code: " << e.code() << ", e.displayText() = " << text << ", e.what() = " << e.what();
stream << "Code: " << e.code() << ", e.displayText() = " << text;
if (with_stacktrace && !has_embedded_stack_trace)
stream << ", Stack trace:\n\n" << e.getStackTrace().toString();

View File

@ -33,6 +33,7 @@ public:
Exception * clone() const override { return new Exception(*this); }
void rethrow() const override { throw *this; }
const char * name() const throw() override { return "DB::Exception"; }
const char * what() const throw() override { return message().data(); }
/// Add something to the existing message.
void addMessage(const std::string & arg) { extendedMessage(arg); }

View File

@ -20,7 +20,7 @@ function ch_url() {
# Check correct exceptions handling
exception_pattern="displayText() = DB::Exception:[[:print:]]* e\.what() = DB::Exception"
exception_pattern="displayText() = DB::Exception:[[:print:]]*"
function check_only_exception() {
local res=`ch_url "$1" "$2"`