Using exception subtypes
SonarCloud complains about our exception throwing, and I think it makes sense:
If you throw a general exception type, such as std::exception, std::logic_error or std::runtime_error, it forces consumers to catch all exceptions, including unknown exceptions they don’t necessarily know how to handle.
Instead, either throw a subtype that already exists ( for example in
https://wiki.sei.cmu.edu/confluence/display/java/ERR07-J.+Do+not+throw+RuntimeException%2C+Exception%2C+or+Throwable
I took a look at the exceptions. As I see it, it is best to throw your own exception in many places.
Should I create a separate file for my own exception classes? Or place the exception classes in the files in which they are used?
Hi @nils-imhoff , If the exception classes are only used within a single file, I think they might be placed at the beginning of the file. Alternatively, you might create a new file containing the exceptions, if they are used multiple times.