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).
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!
Created attachment 117517 [details] [review] Bug 27833: Add unit tests
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
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>
Created attachment 117547 [details] [review] Bug 27833: Add unit tests Signed-off-by: David Nind <david@davidnind.com>
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>
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>
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>
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>
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>
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>
Good call, I've recently done similar for a few other exceptions. Code reads well, is tested and works as expected. Passing QA
Pushed to master for 21.05, thanks to everybody involved!
Enhancement not pushed to 20.11.x