Bug 20590: Improve Koha::Exceptions in string context
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 16 Apr 2018 15:39:15 +0000 (12:39 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 19 Apr 2018 15:46:04 +0000 (12:46 -0300)
commit74e0dfb4376c971d916299827aca1d65cd0852a1
tree75ba521845cee04fb7eea0840f3f7def6400eb07
parent0797d9cc09fdb8e0f1b1e0b5824775ff6286c60a
Bug 20590: Improve Koha::Exceptions in string context

I was working on bug 20580 and noticed that the exceptions are not
stringified and so not really useful when displayed in string context.

This patch is for discussion and not ready for inclusion

Still need to fix:
Koha/REST/V1/Patrons.pm (The error is "Given xxx does not exist")
Koha/Object.pm: in ->store, Koha::Exceptions::Object::FKConstraint is
raised but we cannot set 'value'

Another note: In Koha::Exceptions::Exception I do not have access to
$self->line_number and $self->filename

See also
http://search.cpan.org/~drolsky/Exception-Class-1.44/lib/Exception/Class/Base.pm#OVERRIDING_THE_as_string_METHOD

Test plan:
Apply patch from bug 20580 and execute create_superlibrarian.pl with an
invalid categorycode

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
C4/Members.pm
Koha/Exceptions.pm
Koha/Exceptions/Object.pm