-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The rest of PR #7897 about improvement of exception message #7936
The rest of PR #7897 about improvement of exception message #7936
Conversation
dbms/src/Databases/DatabaseLazy.cpp
Outdated
@@ -361,8 +361,7 @@ StoragePtr DatabaseLazy::loadTable(const Context & context, const String & table | |||
} | |||
catch (const Exception & e) | |||
{ | |||
throw Exception("Cannot create table from metadata file " + table_metadata_path + ", error: " + e.displayText() + | |||
", stack trace:\n" + e.getStackTrace().toString(), | |||
throw Exception("Cannot create table from metadata file " + table_metadata_path + ", error: " + e.displayText() + DB::getCurrentExceptionMessage(true), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I remember correctly, getCurrentExceptionMessage
already includes displayText
.
dbms/src/Databases/DatabaseLazy.cpp
Outdated
@@ -361,8 +361,7 @@ StoragePtr DatabaseLazy::loadTable(const Context & context, const String & table | |||
} | |||
catch (const Exception & e) | |||
{ | |||
throw Exception("Cannot create table from metadata file " + table_metadata_path + ", error: " + e.displayText() + | |||
", stack trace:\n" + e.getStackTrace().toString(), | |||
throw Exception("Cannot create table from metadata file " + table_metadata_path + ", error: " + e.displayText() + DB::getCurrentExceptionMessage(true), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The context of exception is lost.
We must:
- catch by non-const reference and call
e.addMessage
andthrow
(rethrow current exception) to save the stack trace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(this was a small mistake by @nikvas0 that passed review unnoticed)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But do we want to preserve the CANNOT_CREATE_TABLE_FROM_METADATA
?
Perhaps it's better to pass original exception to this ctor, such we have both correct error code and the better stack trace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it can be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it's not necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
@@ -81,8 +81,7 @@ try | |||
catch (const Exception & e) | |||
{ | |||
throw Exception( | |||
"Cannot create object '" + query.table + "' from query " + serializeAST(query) + ", error: " + e.displayText() + ", stack trace:\n" | |||
+ e.getStackTrace().toString(), | |||
"Cannot create object '" + query.table + "' from query " + serializeAST(query) + ". Error: " + DB::getCurrentExceptionMessage(true), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exception context is lost.
@@ -138,8 +137,7 @@ void DatabaseOrdinary::loadStoredObjects( | |||
catch (const Exception & e) | |||
{ | |||
throw Exception( | |||
"Cannot parse definition from metadata file " + full_path + ", error: " + e.displayText() + ", stack trace:\n" | |||
+ e.getStackTrace().toString(), ErrorCodes::CANNOT_PARSE_TEXT); | |||
"Cannot parse definition from metadata file " + full_path + ". Error: " + DB::getCurrentExceptionMessage(true), ErrorCodes::CANNOT_PARSE_TEXT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exception context is lost.
I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en
Changelog category (leave one):