-
-
Notifications
You must be signed in to change notification settings - Fork 480
Allow easy Creation of Generic Exceptions with just a Text #1192
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
Allow easy Creation of Generic Exceptions with just a Text #1192
Conversation
Removed ETL_NOEXCEPT from closureoperator(), call_if(), and call_or()
In addition to removing noexcept from call_if, this is also needed to prevent an abort when cancelling a pthread that is executing a delegate.
Today when using ETL_ASSERT you need to pass a concrete exception type. However, it can be quite unhandy to define a custom exception type for each assert, therefore we want to also allow to simply use the generic etl::exception type and directly provide the message.
WalkthroughThe change adds a new macro ETL_ERROR_UNTYPED(text) in include/etl/error_handler.h. When ETL_VERBOSE_ERRORS is enabled, it expands to etl::exception((text), __FILE__, __LINE__). When disabled, it expands to etl::exception((text), "", __LINE__). This provides a generic exception with a message and location data. Existing macros (e.g., ETL_ERROR, ETL_ERROR_WITH_VALUE) remain unchanged. No other files are modified. Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this 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 (1)
include/etl/error_handler.h (1)
370-375: Align macro argument spacing for consistency.Both new macro invocations omit the space after each comma, unlike the neighbouring macros. Please match the existing formatting so the section stays uniform.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
include/etl/error_handler.h(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
include/etl/*.h
⚙️ CodeRabbit configuration file
include/etl/*.h: Review the C++ code in these directories. The code must not use
STL containers but must instead rely on Embedded Template Library
(ETL) for data structures and algorithms.When answering questions, provide accurate and concise information based on the ETL documentation and codebase. If you don't know the answer, just say "I don't know". Do not make up answers.
When providing code examples, ensure they are relevant to the ETL and follow its conventions.
Always be polite and professional in your responses.Header files should start with the ETL's standard MIT comment block.
Header files should have include guards in the format '#ifndef ETL_>INCLUDED #define ETL_INCLUDED #endif'
Headers should be organized in the following order
- The first header include should be '#include "platform.h"'
- Headers from the ETL
- Headers from the path 'private/**'
- C++ standard library headers
- C standard library headers
Pay extra attention to the following
- Buffer overflows
- Memory leaks
- Undefined behavior
Check that the following conventions are used
- Variable names should be in
snake_case- Macro constants should be
ALL_CAPS_WITH_UNDERSCORES- Macro constants should be prefixed with 'ETL_'
- Function, class, and type names should be
snake_case- enum members should be
Caps_Snake_CasePlease keep your outputs short and to the point, unless otherwise asked
- Keep your responses short, describe small issues in a few sentences
- Don't output tips, analysis chains or anything else with a collapsible view
- Don't output
comment summariesorfix prompts for AIs- If the highlighted issue is complex, don't suggest a solution
- Don't use emojis
Files:
include/etl/error_handler.h
|
I will merge this, but I may change the macro name. |
…-Exceptions-with-just-a-Text' into chru-error-untyped
4cbc601
into
ETLCPP:pull-request/#1192-Allow-easy-Creation-of-Generic-Exceptions-with-just-a-Text
* Removed ETL_NOEXCEPT from delegate operator(), call_if(), and call_or() Removed ETL_NOEXCEPT from closureoperator(), call_if(), and call_or() * Updated version and release notes * Updated version and release notes * Remove noexcept from delegate method stubs. (#1185) In addition to removing noexcept from call_if, this is also needed to prevent an abort when cancelling a pthread that is executing a delegate. * Updated version and release notes * Allow easy Creation of Generic Exceptions with just a Text Today when using ETL_ASSERT you need to pass a concrete exception type. However, it can be quite unhandy to define a custom exception type for each assert, therefore we want to also allow to simply use the generic etl::exception type and directly provide the message. --------- Co-authored-by: John Wellbelove <[email protected]> Co-authored-by: Marco Nilsson <[email protected]> Co-authored-by: John Wellbelove <[email protected]>
Today when using ETL_ASSERT you need to pass a concrete exception type. However, it can be quite unhandy to define a custom exception type for each assert, therefore we want to also allow to simply use the generic etl::exception type and directly provide the message.