Bug 19828: Make Koha::Object->store translate DBIC exceptions into Koha exceptions
authorTomas Cohen Arazi <tomascohen@theke.io>
Mon, 18 Dec 2017 16:48:56 +0000 (13:48 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 22 Dec 2017 16:15:38 +0000 (13:15 -0300)
commit84a8f09ec2b4288092f6035555fa91b400a015ef
tree06226e67671df7f6b0e57ce4449570db7663137a
parent122f5441323cb257fd0aaa171e2f00c7dfbcf189
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>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Koha/Exceptions/Object.pm
Koha/Object.pm