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

Added message on singleton exception. #6

Closed
wants to merge 1 commit into from

Conversation

Klaim
Copy link

@Klaim Klaim commented Oct 20, 2011

I've been hunting for this exception with no message for an hour. I have some try/catch with std::exception that makes gdb not break when this is thrown, because it is catch but there is no what() so I didn't knew where it came from.
This is just an addition of message that state clearly where the exception comes from and why.
Maybe the message could be enhanced, obviously.

I didn't compile this yet.

…ave some try/catch with std::exception that makes gdb not break when this is thrown, because it is catch but there is no what() so I didn't knew where it came from.

This is just an addition of message that state clearly where the exception comes from and why. 
Maybe the message could be enhanced, obviously.

I didn't compile this yet.
@ewencp
Copy link
Member

ewencp commented Oct 20, 2011

Actually, I'm not sure why this code throws an exception. The whole point of the name AutoSingleton is that it self-instantiates if you access it before explicitly instantiating it. It looks like 1dfef33 introduced the change, but doesn't have a comment as to why the change was made. @pathorn or @KevinGadd, do you remember why that change was made?

@Klaim
Copy link
Author

Klaim commented Oct 21, 2011

Well it seems that this class follow the right pattern of forcing the user to call the creation function before doing anything with the singleton. I forgot to call it that's why I got the exception, so it's fine for me. The main problem is more that the exception itself wasn't as useful as it should have been.

@kg
Copy link

kg commented Oct 21, 2011

Yeah, it's not meaningful to use the singleton without having initialized Berkelium first. I don't know why the exception has no message, though.

@Klaim
Copy link
Author

Klaim commented Oct 21, 2011

Laziness? :D

I guess it's because there is no clear error strategy defined for the project, so the one who added the exception didn't know what to do exactly and did the simplest thing.

Also, shouldn't it be exception_runtime?

@ewencp
Copy link
Member

ewencp commented Oct 21, 2011

I fixed this slightly differently than the submitted patch in d7e6c9f, including changes to get rid of the name AutoSingleton since it is no longer accurate. Thanks for the initial version!

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.

3 participants