},
);
-1;
\ No newline at end of file
+1;
);
}
catch {
- if ( $_->isa('DBIx::Class::Exception') ) {
- return $c->render( status => 500,
- openapi => { error => $_->{msg} } );
- }
- else {
- return $c->render( status => 500,
- openapi => { error => "Something went wrong, check the logs. $_" } );
- }
+ $c->unhandled_exception($_);
};
}
);
}
catch {
- if ( $_->isa('Koha::Exceptions::Exception') ) {
- return $c->render(
- status => 500,
- openapi => { error => "Unhandled exception ($_)" }
- );
- }
- else {
- return $c->render(
- status => 500,
- openapi => { error => "Something went wrong, check the logs. ($_)" }
- );
- }
+ $c->unhandled_exception($_);
};
}
);
}
- my $embed = $c->stash('koha.embed');
+ return try {
+ my $embed = $c->stash('koha.embed');
- return $c->render(
- status => 200,
- openapi => $order->to_api({ embed => $embed })
- );
+ return $c->render(
+ status => 200,
+ openapi => $order->to_api({ embed => $embed })
+ );
+ }
+ catch {
+ $c->unhandled_exception($_);
+ };
}
=head3 add
);
}
catch {
- unless ( blessed $_ && $_->can('rethrow') ) {
- return $c->render(
- status => 500,
- openapi => {
- error =>
- "Something went wrong, check Koha logs for details."
- }
- );
- }
- if ( $_->isa('Koha::Exceptions::Object::DuplicateID') ) {
+ if ( blessed $_ and $_->isa('Koha::Exceptions::Object::DuplicateID') ) {
return $c->render(
status => 409,
openapi => { error => $_->error, conflict => $_->duplicate_id }
);
}
- else {
- return $c->render(
- status => 500,
- openapi => { error => "$_" }
- );
- }
+
+ $c->unhandled_exception($_);
};
}
);
}
catch {
- if ( $_->isa('Koha::Exceptions::Exception') ) {
- return $c->render(
- status => 500,
- openapi => { error => "Unhandled exception ($_)" }
- );
- }
- else {
- return $c->render(
- status => 500,
- openapi => { error => "Something went wrong, check the logs." }
- );
- }
+ $c->unhandled_exception($_);
};
}
);
}
catch {
- if ( $_->isa('Koha::Exceptions::Exception') ) {
- return $c->render(
- status => 500,
- openapi => { error => "Unhandled exception ($_)" }
- );
- }
- else {
- return $c->render(
- status => 500,
- openapi => { error => "Something went wrong, check the logs." }
- );
- }
+ $c->unhandled_exception($_);
};
}
);
}
catch {
- if ( $_->isa('DBIx::Class::Exception') ) {
- return $c->render( status => 500,
- openapi => { error => $_->{msg} } );
- }
- else {
- return $c->render( status => 500,
- openapi => { error => "Something went wrong, check the logs." } );
- }
+ $c->unhandled_exception($_);
};
}
openapi => { error => "Vendor not found" } );
}
- return $c->render(
- status => 200,
- openapi => $vendor->to_api
- );
+ return try {
+ return $c->render(
+ status => 200,
+ openapi => $vendor->to_api
+ );
+ }
+ catch {
+ $c->unhandled_exception($_);
+ };
}
=head3 add
);
}
catch {
- if ( $_->isa('DBIx::Class::Exception') ) {
- return $c->render( status => 500,
- openapi => { error => $_->msg } );
- }
- else {
- return $c->render( status => 500,
- openapi => { error => "Something went wrong, check the logs." } );
- }
+ $c->unhandled_exception($_);
};
}
}
catch {
if ( not defined $vendor ) {
- return $c->render( status => 404,
- openapi => { error => "Object not found" } );
- }
- elsif ( $_->isa('Koha::Exceptions::Object') ) {
- return $c->render( status => 500,
- openapi => { error => $_->message } );
- }
- else {
- return $c->render( status => 500,
- openapi => { error => "Something went wrong, check the logs." } );
+ return $c->render(
+ status => 404,
+ openapi => { error => "Object not found" }
+ );
}
+
+ $c->unhandled_exception($_);
+
};
}
sub delete {
my $c = shift->openapi->valid_input or return;
- my $vendor;
-
return try {
- $vendor = Koha::Acquisition::Booksellers->find( $c->validation->param('vendor_id') );
+ my $vendor = Koha::Acquisition::Booksellers->find( $c->validation->param('vendor_id') );
+
+ unless ( $vendor ) {
+ return $c->render(
+ status => 404,
+ openapi => { error => "Object not found" }
+ );
+ }
+
$vendor->delete;
- return $c->render( status => 200,
- openapi => q{} );
+
+ return $c->render(
+ status => 200,
+ openapi => q{}
+ );
}
catch {
- if ( not defined $vendor ) {
- return $c->render( status => 404,
- openapi => { error => "Object not found" } );
- }
- elsif ( $_->isa('DBIx::Class::Exception') ) {
- return $c->render( status => 500,
- openapi => { error => $_->msg } );
- }
- else {
- return $c->render( status => 500,
- openapi => { error => "Something went wrong, check the logs." } );
- }
+ $c->unhandled_exception($_);
};
-
}
1;
}
}
catch {
- return $c->render(
- status => 500,
- openapi => { error => "Something went wrong, check the logs ($_)" }
- );
+ $c->unhandled_exception($_);
};
}
}
}
catch {
- if ( $_->isa('DBIx::Class::Exception') ) {
- return $c->render(
- status => 500,
- openapi => { error => $_->{msg} }
- );
- }
- else {
- return $c->render(
- status => 500,
- openapi => { error => "Something went wrong, check the logs." }
- );
- }
+ $c->unhandled_exception($_);
};
}
return $c->render( status => 200, openapi => $checkouts->to_api );
} catch {
- if ( $_->isa('DBIx::Class::Exception') ) {
- return $c->render(
- status => 500,
- openapi => { error => $_->{msg} }
- );
- } else {
- return $c->render(
- status => 500,
- openapi => { error => "Something went wrong, check the logs." }
- );
- }
+ $c->unhandled_exception($_);
};
}
);
}
- return $c->render(
- status => 200,
- openapi => $checkout->to_api
- );
+ return try {
+ return $c->render(
+ status => 200,
+ openapi => $checkout->to_api
+ );
+ }
+ catch {
+ $c->unhandled_exception($_);
+ };
}
=head3 renew
);
}
- my $borrowernumber = $checkout->borrowernumber;
- my $itemnumber = $checkout->itemnumber;
+ return try {
+ my $borrowernumber = $checkout->borrowernumber;
+ my $itemnumber = $checkout->itemnumber;
+
+ my ($can_renew, $error) = C4::Circulation::CanBookBeRenewed(
+ $borrowernumber, $itemnumber);
+
+ if (!$can_renew) {
+ return $c->render(
+ status => 403,
+ openapi => { error => "Renewal not authorized ($error)" }
+ );
+ }
- my ($can_renew, $error) = C4::Circulation::CanBookBeRenewed(
- $borrowernumber, $itemnumber);
+ AddRenewal($borrowernumber, $itemnumber, $checkout->branchcode);
+ $checkout = Koha::Checkouts->find($checkout_id);
- if (!$can_renew) {
+ $c->res->headers->location( $c->req->url->to_string );
return $c->render(
- status => 403,
- openapi => { error => "Renewal not authorized ($error)" }
+ status => 201,
+ openapi => $checkout->to_api
);
}
-
- AddRenewal($borrowernumber, $itemnumber, $checkout->branchcode);
- $checkout = Koha::Checkouts->find($checkout_id);
-
- $c->res->headers->location( $c->req->url->to_string );
- return $c->render(
- status => 201,
- openapi => $checkout->to_api
- );
+ catch {
+ $c->unhandled_exception($_);
+ };
}
=head3 allows_renewal
);
}
- my ($can_renew, $error) = C4::Circulation::CanBookBeRenewed(
- $checkout->borrowernumber, $checkout->itemnumber);
+ return try {
+ my ($can_renew, $error) = C4::Circulation::CanBookBeRenewed(
+ $checkout->borrowernumber, $checkout->itemnumber);
- my $renewable = Mojo::JSON->false;
- $renewable = Mojo::JSON->true if $can_renew;
+ my $renewable = Mojo::JSON->false;
+ $renewable = Mojo::JSON->true if $can_renew;
- my $rule = Koha::CirculationRules->get_effective_rule(
- {
- categorycode => $checkout->patron->categorycode,
- itemtype => $checkout->item->effective_itemtype,
- branchcode => $checkout->branchcode,
- rule_name => 'renewalsallowed',
- }
- );
- return $c->render(
- status => 200,
- openapi => {
- allows_renewal => $renewable,
- max_renewals => $rule->rule_value,
- current_renewals => $checkout->renewals,
- error => $error
- }
- );
+ my $rule = Koha::CirculationRules->get_effective_rule(
+ {
+ categorycode => $checkout->patron->categorycode,
+ itemtype => $checkout->item->effective_itemtype,
+ branchcode => $checkout->branchcode,
+ rule_name => 'renewalsallowed',
+ }
+ );
+ return $c->render(
+ status => 200,
+ openapi => {
+ allows_renewal => $renewable,
+ max_renewals => $rule->rule_value,
+ current_renewals => $checkout->renewals,
+ error => $error
+ }
+ );
+ }
+ catch {
+ $c->unhandled_exception($_);
+ };
}
1;
return $c->render( status => 200, openapi => $cities );
}
catch {
- if ( $_->isa('DBIx::Class::Exception') ) {
- return $c->render( status => 500,
- openapi => { error => $_->{msg} } );
- }
- else {
- return $c->render( status => 500,
- openapi => { error => "Something went wrong, check the logs."} );
- }
+ $c->unhandled_exception($_);
};
}
sub get {
my $c = shift->openapi->valid_input or return;
- my $city = Koha::Cities->find( $c->validation->param('city_id') );
- unless ($city) {
- return $c->render( status => 404,
- openapi => { error => "City not found" } );
- }
+ return try {
+ my $city = Koha::Cities->find( $c->validation->param('city_id') );
+ unless ($city) {
+ return $c->render( status => 404,
+ openapi => { error => "City not found" } );
+ }
- return $c->render( status => 200, openapi => $city->to_api );
+ return $c->render( status => 200, openapi => $city->to_api );
+ }
+ catch {
+ $c->unhandled_exception($_);
+ }
}
=head3 add
);
}
catch {
- if ( $_->isa('DBIx::Class::Exception') ) {
- return $c->render(
- status => 500,
- openapi => { error => $_->{msg} }
- );
- }
- else {
- return $c->render(
- status => 500,
- openapi => { error => "Something went wrong, check the logs." }
- );
- }
+ $c->unhandled_exception($_);
};
}
return $c->render( status => 200, openapi => $city->to_api );
}
catch {
- if ( $_->isa('Koha::Exceptions::Object') ) {
- return $c->render( status => 500,
- openapi => { error => $_->message } );
- }
- else {
- return $c->render( status => 500,
- openapi => { error => "Something went wrong, check the logs."} );
- }
+ $c->unhandled_exception($_);
};
}
return $c->render( status => 200, openapi => "" );
}
catch {
- if ( $_->isa('DBIx::Class::Exception') ) {
- return $c->render( status => 500,
- openapi => { error => $_->{msg} } );
- }
- else {
- return $c->render( status => 500,
- openapi => { error => "Something went wrong, check the logs."} );
- }
+ $c->unhandled_exception($_);
};
}
);
}
catch {
- if ( blessed $_ and $_->isa('Koha::Exceptions::Object') ) {
+ if ( blessed $_ ) {
if ( $_->isa('Koha::Exceptions::Object::FKConstraint') ) {
my $broken_fk = $_->broken_fk;
openapi => $Koha::REST::V1::Clubs::Holds::to_api_mapping->{$broken_fk} . ' not found.'
);
}
- else {
- return $c->render(
- status => 500,
- openapi => { error => "Uncaught exception: $_" }
- );
- }
}
- else {
+ elsif ($_->isa('Koha::Exceptions::ClubHold')) {
return $c->render(
status => 500,
- openapi => { error => "$_" }
+ openapi => { error => $_->description }
);
}
}
- elsif (blessed $_ and $_->isa('Koha::Exceptions::ClubHold')) {
- return $c->render(
- status => 500,
- openapi => { error => $_->description }
- );
- }
- else {
- return $c->render(
- status => 500,
- openapi => { error => "Something went wrong. check the logs." }
- );
- }
+
+ $c->unhandled_exception($_);
};
}
return $c->render( status => 200, openapi => $holds );
}
catch {
- if ( blessed $_ && $_->isa('Koha::Exceptions') ) {
- return $c->render(
- status => 500,
- openapi => { error => "$_" }
- );
- }
- else {
- return $c->render(
- status => 500,
- openapi => { error => "Something went wrong, check Koha logs for details." }
- );
- }
+ $c->unhandled_exception($_);
};
}
openapi => Koha::Holds->new->to_api_mapping->{$broken_fk} . ' not found.'
);
}
- else {
- return $c->render(
- status => 500,
- openapi => { error => "Uncaught exception: $_" }
- );
- }
- }
- else {
- return $c->render(
- status => 500,
- openapi => { error => "$_" }
- );
}
}
- else {
- return $c->render(
- status => 500,
- openapi => { error => "Something went wrong. check the logs." }
- );
- }
+
+ $c->unhandled_exception($_);
};
}
sub edit {
my $c = shift->openapi->valid_input or return;
- my $hold_id = $c->validation->param('hold_id');
- my $hold = Koha::Holds->find( $hold_id );
+ return try {
+ my $hold_id = $c->validation->param('hold_id');
+ my $hold = Koha::Holds->find( $hold_id );
- unless ($hold) {
- return $c->render( status => 404,
- openapi => {error => "Hold not found"} );
- }
+ unless ($hold) {
+ return $c->render( status => 404,
+ openapi => {error => "Hold not found"} );
+ }
- my $body = $c->req->json;
+ my $body = $c->req->json;
- my $pickup_library_id = $body->{pickup_library_id} // $hold->branchcode;
- my $priority = $body->{priority} // $hold->priority;
- # suspended_until can also be set to undef
- my $suspended_until = exists $body->{suspended_until} ? $body->{suspended_until} : $hold->suspend_until;
+ my $pickup_library_id = $body->{pickup_library_id} // $hold->branchcode;
+ my $priority = $body->{priority} // $hold->priority;
+ # suspended_until can also be set to undef
+ my $suspended_until = exists $body->{suspended_until} ? $body->{suspended_until} : $hold->suspend_until;
- my $params = {
- reserve_id => $hold_id,
- branchcode => $pickup_library_id,
- rank => $priority,
- suspend_until => $suspended_until ? output_pref(dt_from_string($suspended_until, 'rfc3339')) : '',
- itemnumber => $hold->itemnumber
- };
+ my $params = {
+ reserve_id => $hold_id,
+ branchcode => $pickup_library_id,
+ rank => $priority,
+ suspend_until => $suspended_until ? output_pref(dt_from_string($suspended_until, 'rfc3339')) : '',
+ itemnumber => $hold->itemnumber
+ };
- C4::Reserves::ModReserve($params);
- $hold->discard_changes; # refresh
+ C4::Reserves::ModReserve($params);
+ $hold->discard_changes; # refresh
- return $c->render(
- status => 200,
- openapi => $hold->to_api
- );
+ return $c->render(
+ status => 200,
+ openapi => $hold->to_api
+ );
+ }
+ catch {
+ $c->unhandled_exception($_);
+ };
}
=head3 delete
return $c->render( status => 404, openapi => { error => "Hold not found." } );
}
- $hold->cancel;
+ return try {
+ $hold->cancel;
- return $c->render( status => 200, openapi => {} );
+ return $c->render( status => 200, openapi => {} );
+ }
+ catch {
+ $c->unhandled_exception($_);
+ };
}
=head3 suspend
if ( blessed $_ and $_->isa('Koha::Exceptions::Hold::CannotSuspendFound') ) {
return $c->render( status => 400, openapi => { error => "$_" } );
}
- else {
- return $c->render(
- status => 500,
- openapi => { error => "Something went wrong. check the logs." }
- );
- }
+
+ $c->unhandled_exception($_);
};
}
return $c->render( status => 204, openapi => {} );
}
catch {
- return $c->render(
- status => 500,
- openapi => { error => "Something went wrong. check the logs." }
- );
+ $c->unhandled_exception($_);
};
}
return $c->render( status => 200, openapi => $priority );
}
catch {
- return $c->render(
- status => 500,
- openapi => { error => "Something went wrong. check the logs." }
- );
+ $c->unhandled_exception($_);
};
}
);
}
catch {
- unless ( blessed $_ && $_->can('rethrow') ) {
- return $c->render(
- status => 500,
- openapi => {
- error =>
- "Something went wrong, check Koha logs for details."
- }
- );
- }
- return $c->render(
- status => 500,
- openapi => { error => "$_" }
- );
+ $c->unhandled_exception($_);
};
}
sub get {
my $c = shift->openapi->valid_input or return;
- my $item;
try {
- $item = Koha::Items->find($c->validation->param('item_id'));
+ my $item = Koha::Items->find($c->validation->param('item_id'));
+ unless ( $item ) {
+ return $c->render(
+ status => 404,
+ openapi => { error => 'Item not found'}
+ );
+ }
return $c->render( status => 200, openapi => $item->to_api );
}
catch {
- unless ( defined $item ) {
- return $c->render( status => 404,
- openapi => { error => 'Item not found'} );
- }
- if ( $_->isa('DBIx::Class::Exception') ) {
- return $c->render( status => 500,
- openapi => { error => $_->{msg} } );
- }
- else {
- return $c->render( status => 500,
- openapi => { error => "Something went wrong, check the logs."} );
- }
+ $c->unhandled_exception($_);
};
}
return $c->render( status => 200, openapi => $libraries );
}
catch {
- unless ( blessed $_ && $_->can('rethrow') ) {
- return $c->render(
- status => 500,
- openapi => { error => "Something went wrong, check Koha logs for details." }
- );
- }
- return $c->render(
- status => 500,
- openapi => { error => "$_" }
- );
+ $c->unhandled_exception($_);
};
}
sub get {
my $c = shift->openapi->valid_input or return;
- my $library_id = $c->validation->param('library_id');
- my $library = Koha::Libraries->find( $library_id );
+ return try {
+ my $library_id = $c->validation->param('library_id');
+ my $library = Koha::Libraries->find( $library_id );
- unless ($library) {
- return $c->render( status => 404,
- openapi => { error => "Library not found" } );
- }
+ unless ($library) {
+ return $c->render( status => 404,
+ openapi => { error => "Library not found" } );
+ }
- return $c->render(
- status => 200,
- openapi => $library->to_api
- );
+ return $c->render(
+ status => 200,
+ openapi => $library->to_api
+ );
+ }
+ catch {
+ $c->unhandled_exception($_);
+ };
}
=head3 add
);
}
catch {
- unless ( blessed $_ && $_->can('rethrow') ) {
- return $c->render(
- status => 500,
- openapi => { error => "Something went wrong, check Koha logs for details." }
- );
- }
- if ( $_->isa('Koha::Exceptions::Object::DuplicateID') ) {
+ if ( blessed $_ && $_->isa('Koha::Exceptions::Object::DuplicateID') ) {
return $c->render(
status => 409,
openapi => { error => $_->error, conflict => $_->duplicate_id }
);
}
- else {
- return $c->render(
- status => 500,
- openapi => { error => "$_" }
- );
- }
+
+ $c->unhandled_exception($_);
};
}
);
}
catch {
- unless ( blessed $_ && $_->can('rethrow') ) {
- return $c->render(
- status => 500,
- openapi => { error => "Something went wrong, check Koha logs for details." }
- );
- }
-
- return $c->render(
- status => 500,
- openapi => { error => "$_" }
- );
+ $c->unhandled_exception($_);
};
}
return $c->render( status => 204, openapi => '');
}
catch {
- unless ( blessed $_ && $_->can('rethrow') ) {
- return $c->render(
- status => 500,
- openapi => { error => "Something went wrong, check Koha logs for details." }
- );
- }
-
- return $c->render(
- status => 500,
- openapi => { error => "$_" }
- );
+ $c->unhandled_exception($_);
};
}
return $c->render( status => 200, openapi => $patrons->to_api );
}
catch {
- if ( $_->isa('DBIx::Class::Exception') ) {
- return $c->render(
- status => 500,
- openapi => { error => $_->{msg} }
- );
- }
- else {
- return $c->render(
- status => 500,
- openapi => { error => "Something went wrong, check the logs." }
- );
- }
+ $c->unhandled_exception($_);
};
}
sub get {
my $c = shift->openapi->valid_input or return;
- my $patron_id = $c->validation->param('patron_id');
- my $patron = Koha::Patrons->find($patron_id);
+ return try {
+ my $patron_id = $c->validation->param('patron_id');
+ my $patron = Koha::Patrons->find($patron_id);
- unless ($patron) {
- return $c->render( status => 404, openapi => { error => "Patron not found." } );
- }
+ unless ($patron) {
+ return $c->render( status => 404, openapi => { error => "Patron not found." } );
+ }
- return $c->render( status => 200, openapi => $patron->to_api );
+ return $c->render( status => 200, openapi => $patron->to_api );
+ }
+ catch {
+ $c->unhandled_exception($_);
+ };
}
=head3 add
);
}
else {
- return $c->render(
- status => 500,
- openapi => { error => "Something went wrong, check Koha logs for details." }
- );
+ $c->unhandled_exception($_);
}
};
}
);
}
else {
- return $c->render(
- status => 500,
- openapi => {
- error =>
- "Something went wrong, check Koha logs for details."
- }
- );
+ $c->unhandled_exception($_);
}
};
}
);
}
else {
- return $c->render(
- status => 500,
- openapi => {
- error =>
- "Something went wrong, check Koha logs for details."
- }
- );
+ $c->unhandled_exception($_);
}
};
}
}
}
catch {
- return $c->render(
- status => 500,
- openapi => {
- error =>
- "Something went wrong, check Koha logs for details. $_"
- }
- );
+ $c->unhandled_exception($_);
};
}
}
}
catch {
- return $c->render(
- status => 500,
- openapi => {
- error =>
- "Something went wrong, check Koha logs for details. $_"
- }
- );
+ $c->unhandled_exception($_);
};
}
return $c->render( status => 404, openapi => { error => "Patron not found." } );
}
- my $account = $patron->account;
-
- # get outstanding debits and credits
- my $debits = $account->outstanding_debits;
- my $credits = $account->outstanding_credits;
-
- return $c->render(
- status => 200,
- openapi => {
- balance => $account->balance,
- outstanding_debits => {
- total => $debits->total_outstanding,
- lines => $debits->to_api
- },
- outstanding_credits => {
- total => $credits->total_outstanding,
- lines => $credits->to_api
- }
- }
- );
+ return try {
+ my $account = $patron->account;
+
+ # get outstanding debits and credits
+ my $debits = $account->outstanding_debits;
+ my $credits = $account->outstanding_credits;
+
+ return $c->render(
+ status => 200,
+ openapi => {
+ balance => $account->balance,
+ outstanding_debits => {
+ total => $debits->total_outstanding,
+ lines => $debits->to_api
+ },
+ outstanding_credits => {
+ total => $credits->total_outstanding,
+ lines => $credits->to_api
+ }
+ }
+ );
+ }
+ catch {
+ $c->unhandled_exception($_);
+ };
}
=head3 add_credit
return $c->render( status => 200, openapi => { account_line_id => $credit->id } );
}
catch {
- if ( blessed $_ && $_->can('rethrow') ) {
- return $c->render(
- status => 400,
- openapi => { error => "$_" }
- );
- }
- else {
- # Exception, rely on the stringified exception
- return $c->render(
- status => 500,
- openapi => { error => "Something went wrong, check the logs" }
- );
- }
+ $c->unhandled_exception($_);
};
}
return $c->render( status => 200, openapi => "" );
}
catch {
- unless ( blessed $_ && $_->can('rethrow') ) {
- return $c->render( status => 500, openapi => { error => "$_" } );
+ if ( blessed $_ and $_->isa('Koha::Exceptions::Password') ) {
+ return $c->render(
+ status => 400,
+ openapi => { error => "$_" }
+ );
}
- # an exception was raised. return 400 with the stringified exception
- return $c->render( status => 400, openapi => { error => "$_" } );
+ $c->unhandled_exception($_);
};
}
return try {
my $dbh = C4::Context->dbh;
unless ( checkpw_internal($dbh, $user->userid, $old_password ) ) {
- Koha::Exceptions::Authorization::Unauthorized->throw("Invalid password");
+ return $c->render(
+ status => 400,
+ openapi => { error => "Invalid password" }
+ );
}
## Change password
return $c->render( status => 200, openapi => "" );
}
catch {
- unless ( blessed $_ && $_->can('rethrow') ) {
- return $c->render( status => 500, openapi => { error => "$_" } );
+ if ( blessed $_ and $_->isa('Koha::Exceptions::Password') ) {
+ return $c->render(
+ status => 400,
+ openapi => { error => "$_" }
+ );
}
- # an exception was raised. return 400 with the stringified exception
- return $c->render( status => 400, openapi => { error => "$_" } );
+ $c->unhandled_exception($_);
};
}
openapi => { error => "Mandatory attribute created_by missing" }
);
}
- else {
- return $c->render(
- status => 500,
- openapi => { error => "Something went wrong, check the logs." }
- );
- }
+
+ $c->unhandled_exception($_);
};
}
);
}
catch {
- if ( $_->isa('Koha::Exceptions::Exception') ) {
- return $c->render(
- status => 500,
- openapi => { error => "$_" }
- );
- }
- else {
- return $c->render(
- status => 500,
- openapi => { error => "Something went wrong, check the logs." }
- );
- }
+ $c->unhandled_exception($_);
};
}
);
}
catch {
- if ( $_->isa('Koha::Exceptions::Exception') ) {
- return $c->render(
- status => 500,
- openapi => { error => "$_" }
- );
- }
- else {
- return $c->render(
- status => 500,
- openapi => { error => "Something went wrong, check the logs." }
- );
- }
+ $c->unhandled_exception($_);
};
}
);
}
catch {
- if ( $_->isa('Koha::Exceptions::Exception') ) {
- return $c->render(
- status => 500,
- openapi => { error => "$_" }
- );
- }
- else {
- return $c->render(
- status => 500,
- openapi => { error => "Something went wrong, check the logs." }
- );
- }
+ $c->unhandled_exception($_);
};
}