This patch adds a new condition to Koha::Object->store so it catches
incorrect value-related DBIC exceptions.
This DBIC exceptions get now translated into
Koha::Exceptions::Object::BadValue exceptions with relevant parameters
passed.
To test:
- Apply the exception and unit tests patches
- Run:
$ kshell
k$ prove t/db_dependent/Koha/Object.t
=> FAIL: Tests fail because this exception handling code is not
implemented
- Apply this patch
- Run:
k$ prove t/db_dependent/Koha/Object.t
=> SUCCESS: Tests pass!
- Sign off :-D
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Charles Farmer <charles.farmer@inLibro.com>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
duplicate_id => $+{key}
);
}
+ elsif( $_->{msg} =~ /Incorrect (?<type>\w+) value: '(?<value>.*)' for column '(?<property>\w+)'/ ) {
+ Koha::Exceptions::Object::BadValue->throw(
+ type => $+{type},
+ value => $+{value},
+ property => $+{property}
+ );
+ }
}
# Catch-all for foreign key breakages. It will help find other use cases
$_->rethrow();