Bug 22417: Handle errors
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: David Cook <dcook@prosentient.com.au> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
9251623b8d
commit
735e9016ba
|
|
@ -27,21 +27,29 @@ sub enqueue {
|
|||
|
||||
my $borrowernumber = C4::Context->userenv->{number}; # FIXME Handle non GUI calls
|
||||
my $json_args = encode_json $job_args;
|
||||
$self->set({
|
||||
status => 'new',
|
||||
type => $job_type,
|
||||
size => $job_size,
|
||||
data => $json_args,
|
||||
enqueued_on => dt_from_string,
|
||||
borrowernumber => $borrowernumber,
|
||||
})->store;
|
||||
my $job_id;
|
||||
$self->_result->result_source->schema->txn_do(
|
||||
sub {
|
||||
$self->set(
|
||||
{
|
||||
status => 'new',
|
||||
type => $job_type,
|
||||
size => $job_size,
|
||||
data => $json_args,
|
||||
enqueued_on => dt_from_string,
|
||||
borrowernumber => $borrowernumber,
|
||||
}
|
||||
)->store;
|
||||
|
||||
my $job_id = $self->id;
|
||||
$job_args->{job_id} = $job_id;
|
||||
$json_args = encode_json $job_args,
|
||||
$job_id = $self->id;
|
||||
$job_args->{job_id} = $job_id;
|
||||
$json_args = encode_json $job_args;
|
||||
|
||||
my $conn = $self->connect;
|
||||
$conn->send({destination => $job_type, body => $json_args});
|
||||
my $conn = $self->connect;
|
||||
$conn->send_with_receipt( { destination => $job_type, body => $json_args } )
|
||||
or Koha::Exception->throw('Job has not been enqueued');
|
||||
}
|
||||
);
|
||||
|
||||
return $job_id;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,6 +46,8 @@
|
|||
Authority record <a href="/cgi-bin/koha/authorities/detail.pl?authid=[% message.authid | uri %]">[% message.authid | html %]</a> has not been modified. An error occurred on modifying it.
|
||||
[% ELSIF message.code == 'authority_modified' %]
|
||||
Bibliographic record <a href="/cgi-bin/koha/authorities/detail.pl?authid=[% message.authid | uri %]">[% message.authid | html %]</a> has successfully been modified.
|
||||
[% ELSIF message.code == 'cannot_enqueue_job' %]
|
||||
Cannot enqueue this job.
|
||||
[% END %]
|
||||
[% IF message.error %]
|
||||
(The error was: [% message.error | html %]. See the Koha logfile for more information).
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ use Modern::Perl;
|
|||
use CGI;
|
||||
use List::MoreUtils qw( uniq );
|
||||
use JSON qw( encode_json );
|
||||
use Try::Tiny;
|
||||
|
||||
use C4::Auth qw( get_template_and_user );
|
||||
use C4::Output qw( output_html_with_http_headers );
|
||||
|
|
@ -149,17 +150,26 @@ if ( $op eq 'form' ) {
|
|||
# We want to modify selected records!
|
||||
my @record_ids = $input->multi_param('record_id');
|
||||
|
||||
my $job_id = Koha::BackgroundJob::BatchUpdateBiblio->new->enqueue(
|
||||
{
|
||||
mmtid => $mmtid,
|
||||
record_type => $recordtype,
|
||||
record_ids => \@record_ids,
|
||||
}
|
||||
);
|
||||
$template->param(
|
||||
view => 'enqueued',
|
||||
job_id => $job_id,
|
||||
);
|
||||
try {
|
||||
my $job_id = Koha::BackgroundJob::BatchUpdateBiblio->new->enqueue(
|
||||
{
|
||||
mmtid => $mmtid,
|
||||
record_type => $recordtype,
|
||||
record_ids => \@record_ids,
|
||||
}
|
||||
);
|
||||
$template->param(
|
||||
view => 'enqueued',
|
||||
job_id => $job_id,
|
||||
);
|
||||
} catch {
|
||||
push @messages, {
|
||||
type => 'error',
|
||||
code => 'cannot_enqueue_job',
|
||||
error => $_,
|
||||
};
|
||||
$template->param( view => 'errors' );
|
||||
};
|
||||
}
|
||||
|
||||
$template->param(
|
||||
|
|
|
|||
Loading…
Reference in New Issue