Skip to content

Commit f2fd663

Browse files
committed
Suggestion from openwebwork#3043.
Wrap the `unarchiveCourse` call in the `do_unarchive_course` method of the `WeBWorK::ContentGenerator::CourseAdmin` package in an `eval`, so that exceptions are caught. The exceptions are already checked for on the next line, but deal with the exception message better. Instead of displaying `$@` which might include a backtrace, show `$@->message` in the case that `$@` is an object.
1 parent b55c0f4 commit f2fd663

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

lib/WeBWorK/ContentGenerator/CourseAdmin.pm

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,22 +1200,23 @@ sub do_unarchive_course ($c) {
12001200

12011201
my $unarchive_courseID = $c->param('unarchive_courseID') || '';
12021202

1203-
unarchiveCourse(
1204-
newCourseID => $new_courseID,
1205-
archivePath => "$ce->{webworkDirs}{courses}/$ce->{admin_course_id}/archives/$unarchive_courseID",
1206-
ce => $ce,
1207-
);
1203+
eval {
1204+
unarchiveCourse(
1205+
newCourseID => $new_courseID,
1206+
archivePath => "$ce->{webworkDirs}{courses}/$ce->{admin_course_id}/archives/$unarchive_courseID",
1207+
ce => $ce,
1208+
);
1209+
};
12081210

12091211
if ($@) {
1210-
my $error = $@;
12111212
return $c->tag(
12121213
'div',
12131214
class => 'alert alert-danger p-1 mb-2',
12141215
$c->c(
12151216
$c->tag(
12161217
'p', $c->maketext('An error occurred while unarchiving the course [_1]:', $unarchive_courseID)
12171218
),
1218-
$c->tag('div', class => 'font-monospace', $error)
1219+
$c->tag('div', class => 'font-monospace', ref $@ ? $@->message : $@)
12191220
)->join('')
12201221
);
12211222
} else {

0 commit comments

Comments
 (0)