misc: inherit publicly from std::exception#30027
Conversation
Several exception classes used private inheritance from `std::exception` (the default for `class`). This prevents catch(const std::exception&) from matching and causes `exception_ptr` formatting to print only the type name instead of the full `what()` message.
There was a problem hiding this comment.
Pull request overview
This PR fixes several custom exception types that were inadvertently inheriting privately from std::exception (the default for class), which prevented them from being caught via catch(const std::exception&) and reduced the usefulness of exception formatting/logging that relies on what().
Changes:
- Switches multiple exception classes to
public std::exceptioninheritance so they behave as properstd::exceptionsubtypes. - Improves debuggability/observability by enabling standard exception handling patterns and
exception_ptr-based reporting to accesswhat()where implemented.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/v/wasm/parser/leb128.h | Make decode_exception publicly derive from std::exception. |
| src/v/rpc/exceptions.h | Make request_timeout_exception publicly derive from std::exception. |
| src/v/net/batched_output_stream.h | Make batched_output_stream_closed publicly derive from std::exception. |
| src/v/iceberg/transform_utils.h | Make partition_spec_field_error publicly derive from std::exception. |
| src/v/datalake/partition_key_path.h | Make partition_key_error publicly derive from std::exception. |
| src/v/cloud_storage_clients/s3_error.h | Make rest_error_response publicly derive from std::exception. |
| src/v/cloud_storage_clients/abs_error.h | Make abs_rest_error_response publicly derive from std::exception. |
CI test resultstest results on build#82593
|
wut? that's unexpected. do you have a reference to the rule? |
i wonder if this should be a clang-tidy thing. it seems like getting a warning/compilation error would make sense if you try to do something that can never happen! |
I think https://clang.llvm.org/extra/clang-tidy/checks/bugprone/std-exception-baseclass.html catches this |
Do you enjoy reading the C++ standard? https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/n4950.pdf#page=466
3.2 is the relevant bullet point here. |
Nice. Should we error on it? |
|
Ah, only available in |
|
Several exception classes used private inheritance from
std::exception(the default forclass). This preventscatch(const std::exception&)from matching, and causesexception_ptrformatting to print only the type name instead of the fullwhat()message.I discovered this when trying to debug an
ERRORlog line which wasn't very helpful:from
redpanda/src/v/cloud_storage_clients/multipart_upload.cc
Lines 169 to 175 in 32b08d7
Backports Required
Release Notes