Opened 16 years ago
Closed 14 years ago
#281 closed enhancement (fixed)
exceptional style
Reported by: | Peter | Owned by: | Jari Häkkinen |
---|---|---|---|
Priority: | major | Milestone: | yat 0.7 |
Component: | utility | Version: | |
Keywords: | Cc: |
Description
Sometimes when things are thrown, it is confusing and not obvious from where they were thrown. Especially if you are using more than one library, it does help to know that it was yat that threw.
I suggest that we start every what() string with "yat:", and in particular our own Exceptions. At time being, e.g., GSL_error starts with "GSL_error", which, unless you hardcore yat familiar, leads you suspect some error was detected inside GSL.
Also I suggest that we follow the recommended : throw by value, catch by reference.
The first part needs no motivation. The last part is to avoid slicing of classes. It is pretty common to inherit from Exception classes (concrete ones). If you catch by value, there is a call to copy constructor and a risk that you call the wrong copy constructor and thereby slice the classes. Remember: Sliced bread is good. Sliced classes are not.
Change History (4)
comment:1 Changed 16 years ago by
Milestone: | 0.4 → 0.5 |
---|
comment:2 Changed 15 years ago by
Milestone: | yat 0.5 → yat 0.x+ |
---|
comment:3 Changed 14 years ago by
Milestone: | yat 0.x+ → yat 0.7 |
---|
comment:4 Changed 14 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
I wanna fix this for 0.7. Either yat should only throw yat exceptions, i.e., exception classes defined with theplu::yat namespace, or the
what
should include yat so it is obvious from where the exception comes.