Bug 21685 - Name our exceptions consistently
Summary: Name our exceptions consistently
Status: In Discussion
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-10-26 14:04 UTC by Jonathan Druart
Modified: 2019-12-13 09:30 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Druart 2018-10-26 14:04:27 UTC
Few examples of inconsistencies:

*
Koha::Exceptions::WrongParameter
Koha::Exceptions::BadParameter

*
Koha::Exceptions::CannotDeleteDefault
Koha::Exceptions::Patron::FailedDelete

*
Koha::Exceptions::Account::IsNotCredit
Koha::Exceptions::Password::Invalid
=> IsNotCredit vs NotCredit
=> IsNotValid vs Invalid vs NotValid

*
Koha::Exceptions::DuplicateObject
Koha::Exceptions::Object::DuplicateID

It would be good a write a guideline and adapt existing occurrences.
Comment 1 Jonathan Druart 2018-10-26 18:37:08 UTC
CCing some of you, how do you feel about that? Any good practices you have in mind? It would be good to have something on the wiki.
Comment 2 Martin Renvoize 2019-12-13 09:26:53 UTC
Agreed it would be nice to build a consistent pattern and add a guideline to help work towards that... we also don't always subclass and so exceptions are hard to find sometimes which I think is what leads to the nearly duplicate ones you have discovered.

I'd even go so far as to ask the question of whether it's worth us starting to take on a more consistent approach with our objects in general.. We already actually have Moo as a dependency, we could start using some of its recommendations today if we wanted to for type checking etc.  We're also doing a poor mans version of method signatures in a few cases now.. perhaps we should start advocating something there too?
Comment 3 Martin Renvoize 2019-12-13 09:30:58 UTC
(In reply to Martin Renvoize from comment #2)
> I'd even go so far as to ask the question of whether it's worth us starting
> to take on a more consistent approach with our objects in general.. We
> already actually have Moo as a dependency, we could start using some of its
> recommendations today if we wanted to for type checking etc.  We're also
> doing a poor mans version of method signatures in a few cases now.. perhaps
> we should start advocating something there too?

To clarify that a bit.. I'm thinking of something along the lines of Function::Parameters + Type::Tiny