-
Notifications
You must be signed in to change notification settings - Fork 5
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
Update throws to use an exception instead of a string literal #113
Comments
Hello @prestoncarman I agree with the sentiment. But I am not sure how to make that so that it is most helpful. Do you know of any guidelines, design structures, best practices, that should be followed when using exceptions in C++? In particular it seems that the community has been going back and force on whether the function prototype should explicitely indicate that they throw exceptinos or not. Can you point us in the right direction maybe? |
Hi @esaule, To find some answers to your question about standards, I went to two of my c++ textbooks and found they had different points of view (one for strings, the other for exception classes). Then I decided to check out the Google Style guidelines https://google.github.io/styleguide/cppguide.html#Exceptions in which they say to not use exceptions at all. This is primarily because they have a large enough code base without exceptions. It appears not easy to integrate exception code with non-exception code and so they will continue without exceptions in their code, although they do have an exemption for Windows based code. Jumping to Microsoft, I found a nice developers guide https://docs.microsoft.com/en-us/cpp/cpp/exception-handling-in-visual-cpp?view=msvc-160 to using exceptions in C++ code. I guess this could be a good model to follow. |
We are still looking into this. We'll probably make some changes during summer. I am still collecting ressources on how to use exceptions properly to be as useful as possible. This seems like a place to start:
|
https://stackoverflow.com/questions/27179011/c-exception-throw-a-string
Its not a good idea to throw a string. It should be a C++ Exception. Search the repository and replace each throw with an appropriate exception.
The text was updated successfully, but these errors were encountered: