I am writing some library functions that needs to do some error reporting. I want to use exceptions rather than return values.
I wrote my functions that throws int exceptions.
Eg:
if(strm->atEnd()){
// unexpected end of stream
throw -2;
}
My question is, is this method OK? Or should I throw a exception derived from std::exception?
In what way is throwing a std::exception better? (Other than being able to use catch(std::exception &e))
Is throwing int exceptions bad practice? (all throw int values are documented in doxygen comments)
I can't find any reason as to why (in this case) should I throw an object.