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

feat(error_handling): Migrate TraceableException from CLP with changes: #43

Merged
merged 12 commits into from
Apr 8, 2025

Conversation

Bill-hbrhbr
Copy link
Collaborator

@Bill-hbrhbr Bill-hbrhbr commented Mar 23, 2025

Description

Migrate TraceableException to ystdlib-cpp and makes the following changes:

  • Replace __FILENAME__ and __LINE__ macros with std::source_location.
    • Rationale: Now we can simply write throw OperationFailed(error_code); while still getting the file and line number at the call site due to std::source_location default function parameter substitution.
    • std::source_location also provides the fully qualified call site function name, which helps us to eliminate duplicate std::exception::what() overriding specifications that simply repeat the operation classes and/or their namespaces.
  • Add a new parameter message to allow users to specify custom error messages.
    • Rationale: Removing the previous what() overrides allows users greater flexibility in defining custom error messages.
    • Defaults to a pretty print of the call site location information if omitted.
  • Add YSTDLIB_ERROR_HANDLING_DEFINE_TRACEABLE_EXCEPTION(type_name) macro for simplified definitions.
    • Rationale: simplify the definition of a class inheriting TraceableException to a one-liner.
    • Replace a typical definition of OperationFailed with YSTDLIB_ERROR_HANDLING_DEFINE_TRACEABLE_EXCEPTION(OperationFailed)
  • Use absolute paths instead of relative paths for file locations.
    • Rationale: Since ystdlib::error_handling::TraceableException may be used by multiple projects in various locations within the filesystem, it is not always possible to calculate the relative path of a source file.
    • If users prefer relative paths, they can implement a custom wrapper around the TraceableException class.

Checklist

  • The PR satisfies the contribution guidelines.
  • This is a breaking change and that has been indicated in the PR title, OR this isn't a
    breaking change.
  • Necessary docs have been updated, OR no docs need to be updated.

Validation performed

  • Newly added unit test test_TraceableException.cpp passes.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced a new TraceableException class for enhanced error handling with detailed diagnostic context.
    • Added utility functions for formatting error context, improving error reporting integration.
    • New public headers and test source files have been added to enhance the library's interface and testing framework.
  • Tests

    • Expanded test coverage with new tests for the TraceableException class, validating its functionality and context capture.

Copy link

coderabbitai bot commented Mar 23, 2025

Walkthrough

This update introduces new components to the error handling library. A new exception class, TraceableException, is defined with constructors, methods for error and location reporting, and a macro to facilitate subclass creation. Additionally, a utility header provides an overload for streaming source location details. The build configuration is modified to publish these headers and include a new test source to validate the exception's functionality through a Worker class and an exception capture mechanism.

Changes

File(s) Change Summary
src/ystdlib/error_handling/CMakeLists.txt Updated to add public headers (TraceableException.hpp, utils.hpp) and the test source file (test/test_TraceableException.cpp).
src/ystdlib/error_handling/TraceableException.hpp Introduced the TraceableException class with extended constructors, methods, and a macro for defining subclass exceptions.
src/ystdlib/error_handling/test/test_TraceableException.cpp Added test cases including a Worker class with static methods and template functions to capture and validate thrown exceptions.
src/ystdlib/error_handling/utils.hpp Added an inline operator<< overload for std::source_location to enable formatted output.

Sequence Diagram(s)

sequenceDiagram
    participant Test as Catch2 Test
    participant Worker
    participant Exception as TraceableException

    Test->>Worker: Call execute_with_success()
    Worker-->>Test: Throw TraceableException (success)
    Test->>Worker: Call execute_with_failure()
    Worker-->>Test: Throw TraceableException (failure with details)
    Test->>Worker: Invoke capture_exception(lambda)
    Worker-->>Test: Return captured exception details
Loading

Suggested Reviewers

  • davidlion
  • LinZhihao-723
  • kirkrodrigues

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 57b0937 and a30d207.

📒 Files selected for processing (1)
  • src/ystdlib/error_handling/TraceableException.hpp (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/ystdlib/error_handling/TraceableException.hpp
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: lint-check (macos-15)
  • GitHub Check: lint-check (ubuntu-24.04)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Bill-hbrhbr Bill-hbrhbr marked this pull request as ready for review March 23, 2025 08:34
@Bill-hbrhbr Bill-hbrhbr requested a review from a team as a code owner March 23, 2025 08:34
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (5)
src/ystdlib/error_handling/TraceableException.hpp (2)

33-70: Consider renaming the non-const variant of what().
Having two what() methods with different return types may introduce confusion, even though they serve distinct purposes. A more descriptive name for the non-const variant can improve clarity.


74-82: Macro is helpful but could be replaced by a modern template-based approach.
While the macro expedites the creation of new exception types, leveraging an alias template or a derived class might enhance type safety and readability.

src/ystdlib/error_handling/SourceLocation.hpp (1)

30-36: Clarify which file_name() method is being called.

In format_location, where.file_name() could refer to either the overridden method or the base class method depending on whether the YSTDLIB_CPP_PROJECT_SOURCE_PATH_SIZE macro is defined. Consider explicitly calling the intended method to avoid confusion.

static auto format_location(SourceLocation const& where) -> std::string {
    std::ostringstream oss;
-   oss << where.file_name() << "(" << where.line() << ":" << where.column() << "), function `"
+   oss << where.std::source_location::file_name() << "(" << where.line() << ":" << where.column() << "), function `"
        << where.function_name() << "`";
    return oss.str();
}

Or if you intend to use the potentially overridden method:

static auto format_location(SourceLocation const& where) -> std::string {
    std::ostringstream oss;
+   // Intentionally using the potentially overridden file_name() method
    oss << where.file_name() << "(" << where.line() << ":" << where.column() << "), function `"
        << where.function_name() << "`";
    return oss.str();
}
src/ystdlib/error_handling/test/test_TraceableException.cpp (2)

42-55: Forward declaration may be unnecessary.

The forward declaration of capture_exception at line 44 appears unnecessary since the full definition follows immediately in the same namespace. Consider removing it unless it serves a specific purpose.

namespace {
-template <ErrorCodeType E, typename Callable>
-[[nodiscard]] auto capture_exception(Callable&& f) -> TraceableException<E>;
-
template <ErrorCodeType E, typename Callable>
auto capture_exception(Callable&& f) -> TraceableException<E> {
    try {
        std::forward<Callable>(f)();
    } catch (TraceableException<E>& e) {
        return e;
    }
    assert(false && "The function is expected to throw.");
}
}  // namespace

57-67: Consider adding verification of error codes.

While the test verifies file name, function name, and custom error message, it doesn't verify that the error codes are correctly preserved. Consider adding assertions to check that the error codes match the expected values.

TEST_CASE("test_traceable_exception", "[error_handling][TraceableException]") {
    auto const ex_success{capture_exception<BinaryErrorCode>(Worker::execute_with_success)};
    REQUIRE((0 == std::strcmp(ex_success.where().file_name(), cCurrentFileName)));
    REQUIRE((0 == std::strcmp(ex_success.where().function_name(), cSuccessFuncName)));
+   REQUIRE(ex_success.error_code().value() == BinaryErrorCodeEnum::Success);

    auto const ex_failure{capture_exception<BinaryErrorCode>(Worker::execute_with_failure)};
    REQUIRE((0 == std::strcmp(ex_failure.what(), cCustomFailureDescription)));
    REQUIRE((0 == std::strcmp(ex_failure.where().file_name(), cCurrentFileName)));
    REQUIRE((0 == std::strcmp(ex_failure.where().function_name(), cFailureFuncName)));
+   REQUIRE(ex_failure.error_code().value() == BinaryErrorCodeEnum::Failure);
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5f43a3b and e390fcf.

📒 Files selected for processing (5)
  • CMakeLists.txt (1 hunks)
  • src/ystdlib/error_handling/CMakeLists.txt (1 hunks)
  • src/ystdlib/error_handling/SourceLocation.hpp (1 hunks)
  • src/ystdlib/error_handling/TraceableException.hpp (1 hunks)
  • src/ystdlib/error_handling/test/test_TraceableException.cpp (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}`: - Prefer `false == ` rather than `!`.

**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}: - Prefer false == <expression> rather than !<expression>.

  • src/ystdlib/error_handling/SourceLocation.hpp
  • src/ystdlib/error_handling/TraceableException.hpp
  • src/ystdlib/error_handling/test/test_TraceableException.cpp
🧬 Code Definitions (2)
src/ystdlib/error_handling/TraceableException.hpp (2)
src/ystdlib/error_handling/SourceLocation.hpp (4)
  • where (31-36)
  • where (31-31)
  • nodiscard (18-21)
  • nodiscard (24-24)
src/ystdlib/error_handling/test/test_TraceableException.cpp (1)
  • YSTDLIB_ERROR_HANDLING_DEFINE_TRACEABLE_EXCEPTION (27-27)
src/ystdlib/error_handling/test/test_TraceableException.cpp (2)
src/ystdlib/error_handling/TraceableException.hpp (8)
  • TraceableException (37-44)
  • TraceableException (37-40)
  • TraceableException (46-53)
  • TraceableException (46-50)
  • nodiscard (56-56)
  • nodiscard (59-59)
  • nodiscard (61-61)
  • nodiscard (63-63)
src/ystdlib/error_handling/SourceLocation.hpp (2)
  • nodiscard (18-21)
  • nodiscard (24-24)
🔇 Additional comments (12)
src/ystdlib/error_handling/CMakeLists.txt (2)

6-7: Public header additions look good.
These lines correctly add the new TraceableException.hpp and SourceLocation.hpp to the library's public headers.


11-11: Test source addition is appropriate.
Including test/test_TraceableException.cpp ensures coverage for newly introduced functionality.

CMakeLists.txt (2)

45-49: Use of string(LENGTH ...) to capture source path size is correct.
This approach robustly obtains the project source directory length with trailing slash, preventing path-joining errors.


54-60: Conditional definition of the source path size macro is well-structured.
Defining YSTDLIB_CPP_PROJECT_SOURCE_PATH_SIZE only if present avoids unexpected build issues.

src/ystdlib/error_handling/TraceableException.hpp (2)

1-15: File guards and includes look properly set up.
The header guard and essential includes are well placed, ensuring consistent compilation boundaries.


18-20: Concept definition is clear and robust.
Constraining template parameters to std::error_code or types convertible to it is concise and safe.

src/ystdlib/error_handling/SourceLocation.hpp (2)

1-8: Header inclusions and guards look good.

The file includes all necessary headers and properly defines include guards.


9-16: Good class inheritance implementation.

The SourceLocation class properly inherits from std::source_location and initializes the base class in the constructor. The member initialization using format_location(*this) is a clean approach to initialize the formatted string during construction.

src/ystdlib/error_handling/test/test_TraceableException.cpp (4)

1-12: Includes and using declarations look good.

All necessary headers are included and using declarations are properly applied.


13-22: Constants are well-defined and organized.

The use of an anonymous namespace for test constants is a good practice. The constants for file names and function names are clearly defined.


24-39: Worker class implementation looks good.

The Worker class properly demonstrates both exception throwing scenarios - with and without a custom error message.


60-66: Good use of coding guidelines.

The assertions correctly follow the coding guideline of false == <expression> rather than !<expression> by using 0 == std::strcmp(...) instead of !std::strcmp(...).

@Bill-hbrhbr Bill-hbrhbr requested a review from davidlion April 3, 2025 22:03
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/ystdlib/error_handling/TraceableException.hpp (2)

26-65: Good implementation of the TraceableException template class.

The exception class effectively captures error codes along with source location context, making it much easier to debug errors. The design with template parameter for ErrorType is flexible.

A few observations:

  1. The non-const what() method allows modifying the exception message after construction, which could lead to unexpected behavior if used incorrectly.
  2. The what() const method returns a C-string pointer that could become invalid if the exception object is modified through the non-const what() method.

Consider whether the non-const what() method is necessary, or if it should be renamed to something like modify_message() to make its purpose clearer.


71-81: Consider adding parentheses in the macro definitions.

The current macro definitions could potentially cause issues with operator precedence. Consider adding parentheses around parameters in the macros.

For example:

- #define YSTDLIB_ERROR_HANDLING_DEFINE_TRACEABLE_EXCEPTION(T) \
+ #define YSTDLIB_ERROR_HANDLING_DEFINE_TRACEABLE_EXCEPTION(T) \
    class T : public ystdlib::error_handling::TraceableException<> { \
        using ystdlib::error_handling::TraceableException<>::TraceableException; \
    }

This would help avoid potential issues if the macro is used with complex expressions.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e390fcf and 9b24006.

📒 Files selected for processing (5)
  • src/ystdlib/error_handling/CMakeLists.txt (1 hunks)
  • src/ystdlib/error_handling/TraceableException.hpp (1 hunks)
  • src/ystdlib/error_handling/test/test_TraceableException.cpp (1 hunks)
  • src/ystdlib/error_handling/types.hpp (1 hunks)
  • src/ystdlib/error_handling/utils.hpp (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/ystdlib/error_handling/test/test_TraceableException.cpp
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}`: - Prefer `false == ` rather than `!`.

**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}: - Prefer false == <expression> rather than !<expression>.

  • src/ystdlib/error_handling/utils.hpp
  • src/ystdlib/error_handling/types.hpp
  • src/ystdlib/error_handling/TraceableException.hpp
🧬 Code Definitions (1)
src/ystdlib/error_handling/TraceableException.hpp (1)
src/ystdlib/error_handling/test/test_TraceableException.cpp (1)
  • YSTDLIB_ERROR_HANDLING_DEFINE_TRACEABLE_EXCEPTION (28-28)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: lint-check (ubuntu-24.04)
  • GitHub Check: lint-check (macos-15)
🔇 Additional comments (5)
src/ystdlib/error_handling/types.hpp (1)

7-14: LGTM! Clean concept definition for error code types.

The ErrorCodeType concept is well-defined, allowing both std::error_code and convertible types. This will provide strong compile-time guarantees for template code that needs to work with error codes.

src/ystdlib/error_handling/utils.hpp (1)

7-11: Good stream operator implementation for std::source_location.

The operator provides a clear, formatted output of the source location components. This will be useful for debugging and error reporting.

src/ystdlib/error_handling/CMakeLists.txt (2)

6-8: LGTM! New headers properly added to PUBLIC_HEADERS.

The TraceableException.hpp, types.hpp, and utils.hpp headers are correctly added to the library's public interface.


12-12: LGTM! Test file correctly added.

The test_TraceableException.cpp file has been properly added to the TESTS_SOURCES section.

src/ystdlib/error_handling/TraceableException.hpp (1)

71-81: NOLINT issues in macros could be addressed.

The macros are currently marked with NOLINT for specific issues. Consider addressing these issues in a future update.

@Bill-hbrhbr Bill-hbrhbr changed the title feat(error_handling): Add TraceableException that leverages std::source_location. feat(error_handling): Add TraceableException that leverages std::source_location to propagate errors with contextual information. Apr 4, 2025
@Bill-hbrhbr Bill-hbrhbr changed the title feat(error_handling): Add TraceableException that leverages std::source_location to propagate errors with contextual information. feat(error_handling): Add TraceableException for propagating error codes with context across call layers. Apr 4, 2025
@Bill-hbrhbr Bill-hbrhbr requested a review from davidlion April 8, 2025 01:49
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (5)
src/ystdlib/error_handling/TraceableException.hpp (3)

28-37: Consider clarifying the generated 'what' string.
While using std::ostringstream to capture the std::source_location is convenient, it may not be obvious what the string contains (file, function, or both). For clarity, consider separating lines or labelling the data to make it more human-readable, especially if logs or client code rely on parsing these messages.


39-46: Confirm uniform handling of error messages.
When using the second constructor, m_what is directly assigned the custom message. Consider ensuring consistency so that even custom messages may optionally include location details or other helpful context if desired.


69-73: Investigate removing the NOLINT directives.
The macro currently suppresses warnings related to macro usage. If possible, fix any underlying issues to remove the lint suppression. Otherwise, document the rationale for keeping these directives.

src/ystdlib/error_handling/test/test_TraceableException.cpp (2)

26-37: Validate use of operation-specific exception.
Throwing OperationFailed with BinaryErrorCodeEnum::Success might be counterintuitive if the name implies failure. Consider renaming or adding a success-specific exception if your domain logic demands clarity around success paths.


57-66: Consider verifying error_code().
The tests confirm what() and location data but do not verify that error_code().value() matches BinaryErrorCodeEnum::Success or BinaryErrorCodeEnum::Failure. Adding checks would ensure the exception’s error code is properly set.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9b24006 and 193fe11.

📒 Files selected for processing (4)
  • src/ystdlib/error_handling/CMakeLists.txt (1 hunks)
  • src/ystdlib/error_handling/TraceableException.hpp (1 hunks)
  • src/ystdlib/error_handling/test/test_TraceableException.cpp (1 hunks)
  • src/ystdlib/error_handling/utils.hpp (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/ystdlib/error_handling/utils.hpp
  • src/ystdlib/error_handling/CMakeLists.txt
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}`: - Prefer `false == ` rather than `!`.

**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}: - Prefer false == <expression> rather than !<expression>.

  • src/ystdlib/error_handling/TraceableException.hpp
  • src/ystdlib/error_handling/test/test_TraceableException.cpp
🧬 Code Definitions (2)
src/ystdlib/error_handling/TraceableException.hpp (1)
src/ystdlib/error_handling/test/test_TraceableException.cpp (1)
  • YSTDLIB_ERROR_HANDLING_DEFINE_TRACEABLE_EXCEPTION (26-26)
src/ystdlib/error_handling/test/test_TraceableException.cpp (1)
src/ystdlib/error_handling/TraceableException.hpp (8)
  • TraceableException (28-37)
  • TraceableException (28-31)
  • TraceableException (39-46)
  • TraceableException (39-43)
  • nodiscard (49-49)
  • nodiscard (52-52)
  • nodiscard (54-54)
  • nodiscard (56-56)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: lint-check (ubuntu-24.04)
  • GitHub Check: lint-check (macos-15)

Comment on lines +49 to +56
[[nodiscard]] auto what() const noexcept -> char const* override { return m_what.c_str(); }

// Methods
[[nodiscard]] auto error_code() const -> std::error_code { return m_error_code; }

[[nodiscard]] auto what() -> std::string& { return m_what; }

[[nodiscard]] auto where() const noexcept -> std::source_location const& { return m_where; }
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Avoid overloading 'what' with differing return types.
Having both what() const noexcept -> char const* (line 49) and what() -> std::string& (line 54) can cause confusion. Callers might expect the standard signature only. If read–write access to m_what is needed, consider offering a different named method.

Comment on lines +41 to +53
namespace {
template <typename Callable>
[[nodiscard]] auto capture_exception(Callable&& f) -> TraceableException;

template <typename Callable>
auto capture_exception(Callable&& f) -> TraceableException {
try {
std::forward<Callable>(f)();
} catch (TraceableException& e) {
return e;
}
assert(false && "The function is expected to throw.");
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance type safety with template constraints.
The capture_exception template returns a TraceableException and expects that exact type to be thrown. If a different type of exception is actually thrown, the code falls through to assert(false). Consider constraining your template to accept callables that are guaranteed to throw TraceableException or handle unexpected exception types more gracefully.

@davidlion davidlion changed the title feat(error_handling): Add TraceableException for propagating error codes with context across call layers. feat(error_handling): Migrate TraceableException from CLP with improvements: Apr 8, 2025
@davidlion davidlion changed the title feat(error_handling): Migrate TraceableException from CLP with improvements: feat(error_handling): Migrate TraceableException from CLP with changes: Apr 8, 2025
Copy link
Member

@davidlion davidlion left a comment

Choose a reason for hiding this comment

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

feat(error_handling): Migrate TraceableException from CLP with changes:

  • Replace __FILENAME__ and __LINE__ macros with std::source_location.
  • Add a new parameter message to allow users to specify custom error messages.
  • Add YSTDLIB_ERROR_HANDLING_DEFINE_TRACEABLE_EXCEPTION(type_name) macro for simplified definitions.
  • Use absolute paths instead of relative paths for file locations.

@davidlion davidlion merged commit f65e98b into y-scope:main Apr 8, 2025
9 checks passed
@Bill-hbrhbr Bill-hbrhbr deleted the add-traceable-exception-lib branch April 8, 2025 05:48
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