Redis exceptions: add proper what() messages#10727
Merged
julianbrost merged 3 commits intomasterfrom Mar 31, 2026
Merged
Conversation
Contributor
jschmidt-icinga
left a comment
There was a problem hiding this comment.
Just a few suggestions. Pretty straight forward otherwise.
fe518b2 to
b6a4963
Compare
Member
Author
|
In addition to what was requests/discussed in the review, I've also added some more |
Contributor
jschmidt-icinga
left a comment
There was a problem hiding this comment.
Other than one last nitpick this looks fine now.
Comment on lines
+313
to
+315
| RedisDisconnected() | ||
| { | ||
| } |
Contributor
There was a problem hiding this comment.
This constructor can be defaulted or just removed.
RedisDisconnected::what() and RedisProtocolError::what() always returned an
empty string. Similarly, BadRedisType::what() and BadRedisInt::what() only
return the value that couldn't be parsed without any information about the
exception type. If only what() is used when printing the exception, as it's
typical, this results in unhelpful log messages like the following when simply
stopping the Redis server:
[2026-02-23 14:33:33 +0100] critical/IcingaDB: Error during receiving the response to a query which has been fired and forgotten: Connection reset by peer [system:104 at /usr/include/boost/asio/detail/reactive_socket_recv_op.hpp:134 in function 'do_complete']
[2026-02-23 14:33:33 +0100] critical/IcingaDB: Error during receiving the response to a query which has been fired and forgotten:
[2026-02-23 14:33:33 +0100] critical/IcingaDB: Error during receiving the response to a query which has been fired and forgotten:
[2026-02-23 14:33:33 +0100] critical/IcingaDB: Cannot connect to redis-1:6379: Connection refused [system:111 at /usr/include/boost/asio/detail/reactive_socket_connect_op.hpp:98 in function 'do_complete']
This commit changes these messages so that something like "Redis disconnected",
"Redis protocol error: bad int: foo", or "Redis protocol error: bad type: ?" is
returned. In doing so, it also removes a member of type std::vector<char> in
BadRedisInt as this is unsafe to use in exceptions (it violates the requirement
that copy constructor and assignment must be nothrow, see
https://en.cppreference.com/w/cpp/error/exception.html#Standard_exception_requirements).
With this commit, the log messages are now a bit more helpful:
[2026-02-23 15:08:23 +0100] critical/IcingaDB: Error during receiving the response to a query which has been fired and forgotten: Connection reset by peer [system:104 at /usr/include/boost/asio/detail/reactive_socket_recv_op.hpp:134 in function 'do_complete']
[2026-02-23 15:08:23 +0100] critical/IcingaDB: Error during receiving the response to a query which has been fired and forgotten: Redis disconnected
[2026-02-23 15:08:23 +0100] critical/IcingaDB: Error during receiving the response to a query which has been fired and forgotten: Redis disconnected
[2026-02-23 15:08:23 +0100] critical/IcingaDB: Cannot connect to redis-1:6379: Connection refused [system:111 at /usr/include/boost/asio/detail/reactive_socket_connect_op.hpp:98 in function 'do_complete']
Use it for consistency, as requested in the PR review.
Remove them as they are redundant, as requested in the PR review.
b6a4963 to
2077645
Compare
Member
Author
|
I've also fixed one more clang-tidy warning by marking |
jschmidt-icinga
approved these changes
Mar 30, 2026
Contributor
jschmidt-icinga
left a comment
There was a problem hiding this comment.
Looks good to me now.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RedisDisconnected::what() and RedisProtocolError::what() always returned an empty string. Similarly, BadRedisType::what() and BadRedisInt::what() only return the value that couldn't be parsed without any information about the exception type. If only what() is used when printing the exception, as it's typical, this results in unhelpful log messages like the following when simply stopping the Redis server:
This commit changes these messages so that something like "Redis disconnected", "Redis protocol error: bad int: foo", or "Redis protocol error: bad type: ?" is returned. In doing so, it also removes a member of type std::vector in BadRedisInt as this is unsafe to use in exceptions (it violates the requirement that copy constructor and assignment must be nothrow, see https://en.cppreference.com/w/cpp/error/exception.html#Standard_exception_requirements).
With this commit, the log messages are now a bit more helpful:
Additionally, some minor cleanup around the exceptions is done: use
BOOST_THROW_EXCEPTION()and remove redundantinlinespecifiers.