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

A new stream-based Panic API #7869

Merged
merged 1 commit into from
May 22, 2024
Merged

A new stream-based Panic API #7869

merged 1 commit into from
May 22, 2024

Conversation

pixelflinger
Copy link
Collaborator

going forward, instead of using the printf style syntax for panics we use the c++ stream syntax

The new macros that replace ASSERT_*CONDITON are

FILAMENT_CHECK_PRECONDITON
FILAMENT_CHECK_POSTCONDITION
FILAMENT_CHECK_ARITIHMETIC

Example usage:

FILAMENT_CHECK_PRECONDITON(condition) << "Message";

The effect is exactly the same as before, but it'll let clients use Abseil's logging facilities.

@pixelflinger pixelflinger added the internal Issue/PR does not affect clients label May 17, 2024
Copy link
Member

@bejado bejado left a comment

Choose a reason for hiding this comment

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

LGTM. Just an observation: if a user does this:

FILAMENT_CHECK_POSTCONDITION(false);

Then we get an empty "reason" string. I wonder if there's a way we can require users to provide a message (if we even want to require it) at compile time. Or, maybe we could provide a default message.

@pixelflinger
Copy link
Collaborator Author

LGTM. Just an observation: if a user does this:

FILAMENT_CHECK_POSTCONDITION(false);

Then we get an empty "reason" string. I wonder if there's a way we can require users to provide a message (if we even want to require it) at compile time. Or, maybe we could provide a default message.

interesting idea. I think we probably can provide the stringified condition. I will give it a shot.

going forward, instead of using the printf style syntax for panics
we use the c++ stream syntax

The new macros that replace ASSERT_*CONDITON are

FILAMENT_CHECK_PRECONDITON
FILAMENT_CHECK_POSTCONDITION
FILAMENT_CHECK_ARITIHMETIC

Example usage:

FILAMENT_CHECK_PRECONDITON(condition) << "Message";

It's also now possible to define FILAMENT_PANIC_USES_ABSL=1 to redirect
all these calls to Abseil's CHECK() macro.
@pixelflinger pixelflinger merged commit 7515884 into main May 22, 2024
11 checks passed
@pixelflinger pixelflinger deleted the ma/new-panic branch May 22, 2024 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal Issue/PR does not affect clients
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants