Skip to content

Conversation

@christophruethingbmw
Copy link
Contributor

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.

John Wellbelove and others added 6 commits September 12, 2025 20:19
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.
@coderabbitai
Copy link

coderabbitai bot commented Sep 26, 2025

Walkthrough

The 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)
Check name Status Explanation
Title Check ✅ Passed The title concisely and accurately describes the primary change, which is enabling users to create generic exceptions with just a text message rather than defining a custom exception type for each assert. It directly reflects the added ETL_ERROR_UNTYPED macro’s purpose without extraneous details.
Description Check ✅ Passed The description clearly outlines the current limitation of ETL_ASSERT requiring concrete exception types and explains the motivation for allowing direct use of the generic etl::exception with a message, which matches the changes introduced.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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 (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

📥 Commits

Reviewing files that changed from the base of the PR and between f9cf20d and d1043f3.

📒 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_Case

Please 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 summaries or fix prompts for AIs
  • If the highlighted issue is complex, don't suggest a solution
  • Don't use emojis

Files:

  • include/etl/error_handler.h

@jwellbelove
Copy link
Contributor

I will merge this, but I may change the macro name.

@jwellbelove jwellbelove changed the base branch from master to pull-request/#1192-Allow-easy-Creation-of-Generic-Exceptions-with-just-a-Text September 28, 2025 09:27
…-Exceptions-with-just-a-Text' into chru-error-untyped
@jwellbelove jwellbelove merged commit 4cbc601 into ETLCPP:pull-request/#1192-Allow-easy-Creation-of-Generic-Exceptions-with-just-a-Text Sep 28, 2025
83 checks passed
jwellbelove added a commit that referenced this pull request Oct 11, 2025
* 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]>
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.

4 participants