1
0

Show error when createPreview fails

This commit is contained in:
Mike Schwörer 2022-10-15 17:13:55 +02:00
parent e54522c3f8
commit 31c0bda8cb
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
3 changed files with 20 additions and 3 deletions

View File

@ -20,7 +20,13 @@ echo '<body>';
foreach ($SITE->modules->Books()->listAll() as $book) foreach ($SITE->modules->Books()->listAll() as $book)
{ {
echo 'Create preview for ' . $book['title'] . '<br/>' . "\n"; echo 'Create preview for ' . $book['title'] . '<br/>' . "\n";
try {
$SITE->modules->Books()->createPreview($book); $SITE->modules->Books()->createPreview($book);
} catch (Exception $e) {
echo '<strong>Failed to create preview for ' . $book['title'] . ':' . $e->getMessage() . '</strong><br/>' . "\n";
}
} }
echo 'Finished.' . '<br/>' . "\n"; echo 'Finished.' . '<br/>' . "\n";

View File

@ -20,7 +20,13 @@ echo '<body>';
foreach ($SITE->modules->Programs()->listAll() as $prog) foreach ($SITE->modules->Programs()->listAll() as $prog)
{ {
echo 'Create preview for ' . $prog['name'] . '<br/>' . "\n"; echo 'Create preview for ' . $prog['name'] . '<br/>' . "\n";
try {
$SITE->modules->Programs()->createPreview($prog); $SITE->modules->Programs()->createPreview($prog);
} catch (Exception $e) {
echo '<strong>Failed to create preview for ' . $prog['name'] . ':' . $e->getMessage() . '</strong><br/>' . "\n";
}
} }
echo 'Finished.' . '<br/>' . "\n"; echo 'Finished.' . '<br/>' . "\n";

View File

@ -176,7 +176,12 @@ function magick_resize_image($file, $width, $height, $output)
$cmd = 'convert "' . $file . '" -strip -resize ' . $final_width . 'x' . $final_height . ' "' . $output . '"'; $cmd = 'convert "' . $file . '" -strip -resize ' . $final_width . 'x' . $final_height . ' "' . $output . '"';
shell_exec($cmd); $output=null;
$retval=null;
$r = exec($cmd, $output, $retval);
if ($r === false) throw new Exception("Magick exec() return FALSE");
if ($retval !== 0) throw new Exception("Magick exec() returned exitcode $retval");
} }
function sendMail($subject, $content, $to, $from) function sendMail($subject, $content, $to, $from)