Bug 39408: Handle BadParameter exception better
Currently we assume BadParameter has been thrown with a parameter that is a valid patron field.
It may only include a message, or it may have come from outside the patron object, we should
handle all cases.
To test:
1 - Wrap "WELCOME" notice content in conditional:
[% IF borrower.categorycode != 'SELFREG' %]
...
[% END %]
2 - Enable preference AutoEmailNewUser
3 - Attempt to self register a patron via API with body:
{"surname":"PATRON","firstname":"PROBLEM","library_id":"CPL","category_id":"SELFREG","email":"eample@example.org"}
4 - Response error: "Given does not exist"
5 - Apply this patch, restart all
6 - Repeat 3
7 - Response error: "Exception 'Koha::Exceptions::BadParameter' thrown 'Parameter message_id cannot be empty if passed.'\n"
8 - It's uglier, but actually helpful
Signed-off-by: Claire Hernandez <claire.hernandez@biblibre.com>
Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
5bad556207
commit
ae14a11937
|
|
@ -183,9 +183,12 @@ sub add {
|
|||
openapi => { error => "Given " . $to_api_mapping->{ $_->broken_fk } . " does not exist" }
|
||||
);
|
||||
} elsif ( $_->isa('Koha::Exceptions::BadParameter') ) {
|
||||
my $parameter = $to_api_mapping->{ $_->parameter } || $_->parameter;
|
||||
my $error =
|
||||
$parameter ? "Given " . $to_api_mapping->{ $_->parameter } . " does not exist" : $_->full_message;
|
||||
return $c->render(
|
||||
status => 400,
|
||||
openapi => { error => "Given " . $to_api_mapping->{ $_->parameter } . " does not exist" }
|
||||
openapi => { error => $error }
|
||||
);
|
||||
} elsif ( $_->isa('Koha::Exceptions::Patron::MissingMandatoryExtendedAttribute') ) {
|
||||
return $c->render(
|
||||
|
|
|
|||
Loading…
Reference in New Issue