Bug 27833 - Koha::Exceptions::Patron::Attribute::* should have parameters
Summary: Koha::Exceptions::Patron::Attribute::* should have parameters
Status: Pushed to master
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Tomás Cohen Arazi
QA Contact: Martin Renvoize
URL:
Keywords:
Depends on: 17828
Blocks: 27858
  Show dependency treegraph
 
Reported: 2021-03-02 12:36 UTC by Tomás Cohen Arazi
Modified: 2021-04-19 10:14 UTC (History)
2 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Text to go in the release notes:
This development adds parameters to the extended attributes-related exceptions. This allows better handling.
Version(s) released in:
21.05.00


Attachments
Bug 27833: Make Koha::Exceptions::Patron::Attribute::* have parameters (4.81 KB, patch)
2021-03-02 14:19 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 27833: Add unit tests (2.26 KB, patch)
2021-03-02 14:19 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 27833: Make K::P::Attribute add the object to the exception (1.58 KB, patch)
2021-03-02 14:19 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 27833: Make Koha::Exceptions::Patron::Attribute::* have parameters (4.87 KB, patch)
2021-03-02 19:02 UTC, David Nind
Details | Diff | Splinter Review
Bug 27833: Add unit tests (2.31 KB, patch)
2021-03-02 19:02 UTC, David Nind
Details | Diff | Splinter Review
Bug 27833: Make K::P::Attribute add the object to the exception (1.62 KB, patch)
2021-03-02 19:02 UTC, David Nind
Details | Diff | Splinter Review
Bug 27833: (follow-up) Add InvalidType exception (4.86 KB, patch)
2021-03-04 10:42 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 27833: Make Koha::Exceptions::Patron::Attribute::* have parameters (4.92 KB, patch)
2021-03-04 12:29 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 27833: Add unit tests (2.37 KB, patch)
2021-03-04 12:29 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 27833: Make K::P::Attribute add the object to the exception (1.69 KB, patch)
2021-03-04 12:30 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 27833: (follow-up) Add InvalidType exception (4.92 KB, patch)
2021-03-04 12:30 UTC, Martin Renvoize
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Tomás Cohen Arazi 2021-03-02 12:36:28 UTC
When one of them is thrown, they should carry the failing code and value. This way we can provide better feedback on the UI (or the API).
Comment 1 Tomás Cohen Arazi 2021-03-02 14:19:27 UTC
Created attachment 117516 [details] [review]
Bug 27833: Make Koha::Exceptions::Patron::Attribute::* have parameters

This patch adds a 'field' to this exceptions. They now have an
'attribute' parameter referencing the object itself,

To test:
1. Apply this patch
2. Run:
   $ kshell
  k$ prove t/Koha/Exceptions.t
=> SUCCESS: Tests pass!
3. Sign off!
Comment 2 Tomás Cohen Arazi 2021-03-02 14:19:30 UTC
Created attachment 117517 [details] [review]
Bug 27833: Add unit tests
Comment 3 Tomás Cohen Arazi 2021-03-02 14:19:33 UTC
Created attachment 117518 [details] [review]
Bug 27833: Make K::P::Attribute add the object to the exception

This patch makes the 'check_unique_id' and '_check_repeatable' methods
pass the 'attribute' parameter when throwing an exception. This way we
can provid emore meaningfull error messages.

To test:
1. Apply the previous patches
2. Run
   $ kshell
  k$ prove t/db_dependent/Koha/Patron/Attributes.t
=> FAIL: The exceptions are not passed the attribute!
3. Apply this patch
4. Repeat 2
=> SUCCESS: Tests pass!
5. Sign off :-D
Comment 4 David Nind 2021-03-02 19:02:44 UTC
Created attachment 117546 [details] [review]
Bug 27833: Make Koha::Exceptions::Patron::Attribute::* have parameters

This patch adds a 'field' to this exceptions. They now have an
'attribute' parameter referencing the object itself,

To test:
1. Apply this patch
2. Run:
   $ kshell
  k$ prove t/Koha/Exceptions.t
=> SUCCESS: Tests pass!
3. Sign off!

Signed-off-by: David Nind <david@davidnind.com>
Comment 5 David Nind 2021-03-02 19:02:47 UTC
Created attachment 117547 [details] [review]
Bug 27833: Add unit tests

Signed-off-by: David Nind <david@davidnind.com>
Comment 6 David Nind 2021-03-02 19:02:50 UTC
Created attachment 117548 [details] [review]
Bug 27833: Make K::P::Attribute add the object to the exception

This patch makes the 'check_unique_id' and '_check_repeatable' methods
pass the 'attribute' parameter when throwing an exception. This way we
can provid emore meaningfull error messages.

To test:
1. Apply the previous patches
2. Run
   $ kshell
  k$ prove t/db_dependent/Koha/Patron/Attributes.t
=> FAIL: The exceptions are not passed the attribute!
3. Apply this patch
4. Repeat 2
=> SUCCESS: Tests pass!
5. Sign off :-D

Signed-off-by: David Nind <david@davidnind.com>
Comment 7 Tomás Cohen Arazi 2021-03-04 10:42:12 UTC
Created attachment 117676 [details] [review]
Bug 27833: (follow-up) Add InvalidType exception

Working on bug 27857 showed we needed one more exception, for when the
passed attribute type is invalid.

This patch adds the Koha::Exceptions::Patron::Attribute::InvalidType
exception. It adds a format for stringifying it, and tests are added.
The previous exceptions tests lacked one case, so I add them on this
patch as well.

To test:
1. Apply this patch
2. Run:
   $ kshell
  k$ prove tt/Koha/Exceptions.t
=> SUCCESS: Tests pass!
3. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 8 Martin Renvoize 2021-03-04 12:29:54 UTC
Created attachment 117701 [details] [review]
Bug 27833: Make Koha::Exceptions::Patron::Attribute::* have parameters

This patch adds a 'field' to this exceptions. They now have an
'attribute' parameter referencing the object itself,

To test:
1. Apply this patch
2. Run:
   $ kshell
  k$ prove t/Koha/Exceptions.t
=> SUCCESS: Tests pass!
3. Sign off!

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 9 Martin Renvoize 2021-03-04 12:29:57 UTC
Created attachment 117702 [details] [review]
Bug 27833: Add unit tests

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 10 Martin Renvoize 2021-03-04 12:30:00 UTC
Created attachment 117703 [details] [review]
Bug 27833: Make K::P::Attribute add the object to the exception

This patch makes the 'check_unique_id' and '_check_repeatable' methods
pass the 'attribute' parameter when throwing an exception. This way we
can provid emore meaningfull error messages.

To test:
1. Apply the previous patches
2. Run
   $ kshell
  k$ prove t/db_dependent/Koha/Patron/Attributes.t
=> FAIL: The exceptions are not passed the attribute!
3. Apply this patch
4. Repeat 2
=> SUCCESS: Tests pass!
5. Sign off :-D

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 11 Martin Renvoize 2021-03-04 12:30:03 UTC
Created attachment 117704 [details] [review]
Bug 27833: (follow-up) Add InvalidType exception

Working on bug 27857 showed we needed one more exception, for when the
passed attribute type is invalid.

This patch adds the Koha::Exceptions::Patron::Attribute::InvalidType
exception. It adds a format for stringifying it, and tests are added.
The previous exceptions tests lacked one case, so I add them on this
patch as well.

To test:
1. Apply this patch
2. Run:
   $ kshell
  k$ prove tt/Koha/Exceptions.t
=> SUCCESS: Tests pass!
3. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 12 Martin Renvoize 2021-03-04 12:30:38 UTC
Good call, I've recently done similar for a few other exceptions.

Code reads well, is tested and works as expected.

Passing QA
Comment 13 Jonathan Druart 2021-04-09 14:40:57 UTC
Pushed to master for 21.05, thanks to everybody involved!
Comment 14 Fridolin Somers 2021-04-19 10:14:37 UTC
Enhancement not pushed to 20.11.x