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

Throw exception instead of pointer to exception #2600

Merged
merged 1 commit into from
Jan 28, 2025
Merged

Conversation

flomnes
Copy link
Member

@flomnes flomnes commented Jan 27, 2025

Explanation

We don't catch AssertionError*, only AssertionError or references to AssertionError.

Code

#include <iostream>
#include <stdexcept>

int main()
{
    try
    {
        throw new std::runtime_error("nope");
    }
    catch (const std::runtime_error& re)
    {
        std::cout << "A " << re.what() << std::endl;
    }
    catch (std::runtime_error* re)
    {
        std::cout << "B " << re->what() << std::endl;
    }
}

Output

B nope

@payetvin payetvin merged commit e62801c into develop Jan 28, 2025
8 of 10 checks passed
@payetvin payetvin deleted the fix/throw-new branch January 28, 2025 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants