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

Streaming values into NTA_THROW does not work. #753

Closed
dkeeney opened this issue Nov 17, 2019 · 2 comments
Closed

Streaming values into NTA_THROW does not work. #753

dkeeney opened this issue Nov 17, 2019 · 2 comments
Labels
bug Something isn't working code code enhancement, optimization, cleanup..programmer stuff

Comments

@dkeeney
Copy link

dkeeney commented Nov 17, 2019

After the Exception code cleanup PR #742 the error messages streamed into NTA_THROW no longer work.

  try {
    NTA_THROW << "This error msg";
  } catch (const Exception &e) {
    EXPECT_STREQ(e.getMessage(), "This error msg");
  }

I added this to the end of ExceptionTest.hpp and it fails. e.getMessage() is empty.
Tried this on Windows 10 using MSVC 2019.

But what I really want is something like: e.what() to return

    Exception:  <full path to module>(<line number>) message:  <message goes here>

It is not obvious to me what changed that broke it.

@breznak breznak added bug Something isn't working code code enhancement, optimization, cleanup..programmer stuff labels Nov 17, 2019
@breznak
Copy link
Member

breznak commented Nov 17, 2019

Thanks David for finding this and sorry for the bug!

@dkeeney
Copy link
Author

dkeeney commented Nov 17, 2019

Found the problem. The copy constructor should be something like:

  Exception(const Exception& copy):
    std::runtime_error("")	{
    filename_ = copy.filename_;
    lineno_ = copy.lineno_;
    message_ = copy.getMessage();   // will add in the streamed fields
    stackTrace_ = copy.stackTrace_;
  }

Could use std::move( ) on those assignments I guess but this is not a high use function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working code code enhancement, optimization, cleanup..programmer stuff
Projects
None yet
Development

No branches or pull requests

2 participants