utils::is_timeout_exception: Ensure we handle nested exception types
Fixes #9922
storage proxy uses is_timeout_exception to traverse different code paths.
a6202ae079 broke this (because bit rot and
intermixing), by wrapping exception for information purposes.
This adds check of nested types in exception handling, as well as a test
for the routine itself.
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include "test/lib/cql_test_env.hh"
|
||||
#include <seastar/core/manual_clock.hh>
|
||||
#include <seastar/testing/test_case.hh>
|
||||
#include <seastar/rpc/rpc_types.hh>
|
||||
#include "utils/error_injection.hh"
|
||||
#include "db/timeout_clock.hh"
|
||||
#include "test/lib/cql_assertions.hh"
|
||||
@@ -184,6 +185,27 @@ SEASTAR_TEST_CASE(test_error_exceptions) {
|
||||
return make_ready_future<>();
|
||||
}
|
||||
|
||||
SEASTAR_TEST_CASE(test_is_timeout_exception) {
|
||||
for (auto ep : {
|
||||
std::make_exception_ptr(seastar::rpc::timeout_error()),
|
||||
std::make_exception_ptr(seastar::semaphore_timed_out()),
|
||||
std::make_exception_ptr(seastar::timed_out_error()),
|
||||
})
|
||||
{
|
||||
BOOST_TEST(is_timeout_exception(ep));
|
||||
try {
|
||||
std::rethrow_exception(ep);
|
||||
} catch (...) {
|
||||
try {
|
||||
std::throw_with_nested(std::runtime_error("Hello"));
|
||||
} catch (...) {
|
||||
BOOST_TEST(is_timeout_exception(std::current_exception()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return make_ready_future<>();
|
||||
}
|
||||
|
||||
SEASTAR_TEST_CASE(test_inject_exception) {
|
||||
utils::error_injection<true> errinj;
|
||||
|
||||
|
||||
@@ -80,6 +80,8 @@ bool is_timeout_exception(std::exception_ptr e) {
|
||||
return true;
|
||||
} catch (seastar::timed_out_error& unused) {
|
||||
return true;
|
||||
} catch (const std::nested_exception& e) {
|
||||
return is_timeout_exception(e.nested_ptr());
|
||||
} catch (...) {
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user