Skip to content
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

Added useful message for thrown exception #48878

Closed
wants to merge 1 commit into from

Conversation

dgeorgi
Copy link

@dgeorgi dgeorgi commented Apr 18, 2023

Issue: #48772

Added try catch blocks to catch an exception thrown, add a message about the parameter that couldn't be parsed then throw new exception.

@alexey-milovidov alexey-milovidov marked this pull request as draft April 18, 2023 12:13
@rschu1ze rschu1ze changed the title Added usefull message for thrown exception Issue: #48772 Added useful message for thrown exception Apr 18, 2023
else
throw Exception(ErrorCodes::UNKNOWN_QUERY_PARAMETER, "Substitution {} is not set", backQuote(name));
else {
try {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try { throw ... } catch looks a bit silly :-) What about including all information in the exception in the first place and not using try/catch? Alternatively, wrap the entire block in try such that a single catch may add all context.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback! Sorry this is my first time working on an open source project (or anything outside of class projects) I'll take a look and clean it up.

" because it isn't parsed completely: only {} of {} bytes was parsed: {}",
value, type_name, ast_param.name, read_buffer.count(), value.size(), value.substr(0, read_buffer.count()));
}
catch (const Exception & e) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps (didn't check closer) function try blocks may help: https://stackoverflow.com/questions/5612486/when-is-a-function-try-block-useful

@rschu1ze rschu1ze self-assigned this Apr 18, 2023
@alexey-milovidov
Copy link
Member

I will rewrite.

@alexey-milovidov
Copy link
Member

@dgeorgi please check the implementation here: #49061

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants