DBIC exceptions are not suitable for reporting end users and API consumers the problems we find. They need to be parsed to find out the root cause of the problems. This could be done in Koha::Object-based classes (see bug 16330 for a discussion on this), but it should be handled more generically, in Koha::Object->store.
Created attachment 69857 [details] [review] Bug 19828: Unit tests This patch introduces unit tests for the changes this bug introduces to Koha::Object->store. To test: - Apply this patch - Run: $ kshell k$ prove t/db_dependent/Koha/Object.t => FAIL: Tests should fail because the changes are not implemented on this patch
Created attachment 69858 [details] [review] Bug 19828: Make Koha::Object->store translate DBIC exceptions into Koha exceptions This patch introduces a try/catch block in store() and parses the error when an exceptional situation takes place. It only deals with FK constraint violations. The rest of the DBIC exceptions are rethrown. To test: - Apply this patch - Run: $ kshell k$ prove t/db_dependent/Koha/Object.t => SUCCESS: Tests pass! - Sign off :-D
Created attachment 69907 [details] [review] Bug 19828: Unit tests This patch introduces unit tests for the changes this bug introduces to Koha::Object->store. To test: - Apply this patch - Run: $ kshell k$ prove t/db_dependent/Koha/Object.t => FAIL: Tests should fail because the changes are not implemented on this patch
Created attachment 69908 [details] [review] Bug 19828: Make Koha::Object->store translate DBIC exceptions into Koha exceptions This patch introduces a try/catch block in store() and parses the error when an exceptional situation takes place. It only deals with FK constraint violations and duplicate IDs. The rest of the DBIC exceptions are rethrown. To test: - Apply this patch - Run: $ kshell k$ prove t/db_dependent/Koha/Object.t => SUCCESS: Tests pass! - Sign off :-D
I added the duplicate key use case.
Created attachment 69963 [details] [review] Bug 19828: Unit tests This patch introduces unit tests for the changes this bug introduces to Koha::Object->store. To test: - Apply this patch - Run: $ kshell k$ prove t/db_dependent/Koha/Object.t => FAIL: Tests should fail because the changes are not implemented on this patch
Created attachment 69964 [details] [review] Bug 19828: Make Koha::Object->store translate DBIC exceptions into Koha exceptions This patch introduces a try/catch block in store() and parses the error when an exceptional situation takes place. It only deals with FK constraint violations and duplicate IDs. The rest of the DBIC exceptions are rethrown. To test: - Apply this patch - Run: $ kshell k$ prove t/db_dependent/Koha/Object.t => SUCCESS: Tests pass! - Sign off :-D
Created attachment 69965 [details] [review] Bug 19828: Fix tests that expect DBD errors instead of the exception message
Created attachment 70048 [details] [review] Bug 19828: Unit tests This patch introduces unit tests for the changes this bug introduces to Koha::Object->store. To test: - Apply this patch - Run: $ kshell k$ prove t/db_dependent/Koha/Object.t => FAIL: Tests should fail because the changes are not implemented on this patch Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Created attachment 70049 [details] [review] Bug 19828: Make Koha::Object->store translate DBIC exceptions into Koha exceptions This patch introduces a try/catch block in store() and parses the error when an exceptional situation takes place. It only deals with FK constraint violations and duplicate IDs. The rest of the DBIC exceptions are rethrown. To test: - Apply this patch - Run: $ kshell k$ prove t/db_dependent/Koha/Object.t => SUCCESS: Tests pass! - Sign off :-D Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Created attachment 70050 [details] [review] Bug 19828: Fix tests that expect DBD errors instead of the exception message Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Created attachment 70097 [details] [review] Bug 19828: Unit tests This patch introduces unit tests for the changes this bug introduces to Koha::Object->store. To test: - Apply this patch - Run: $ kshell k$ prove t/db_dependent/Koha/Object.t => FAIL: Tests should fail because the changes are not implemented on this patch Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Created attachment 70098 [details] [review] Bug 19828: Make Koha::Object->store translate DBIC exceptions into Koha exceptions This patch introduces a try/catch block in store() and parses the error when an exceptional situation takes place. It only deals with FK constraint violations and duplicate IDs. The rest of the DBIC exceptions are rethrown. To test: - Apply this patch - Run: $ kshell k$ prove t/db_dependent/Koha/Object.t => SUCCESS: Tests pass! - Sign off :-D Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Created attachment 70099 [details] [review] Bug 19828: Fix tests that expect DBD errors instead of the exception message Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Created attachment 70100 [details] [review] Bug 19828: (QA follow-up) Fix rethrowing exception and move rethrowing out of 'if' statement just in case the exception does not came from DBIx::Class Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Pushed to master for 18.05, thanks to everybody involved!
Enhancement, skipping for 17.11.x. Awesome work everybody!