Opened 13 years ago

Closed 11 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:


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 13 years ago by Jari Häkkinen

Milestone: 0.40.5

comment:2 Changed 12 years ago by Jari Häkkinen

Milestone: yat 0.5yat 0.x+

comment:3 Changed 11 years ago by Peter

Milestone: yat 0.x+yat 0.7

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.

comment:4 Changed 11 years ago by Peter

Resolution: fixed
Status: newclosed

(In [2210]) fixes #281. Change all throws of std::runtime_error to theplu::yat::utility::runtime_error to clarify that the error comes from yat. Also removed some throw declarations.

Note: See TracTickets for help on using tickets.