word edit: capture image convert error messages
authorMischa POSLAWSKY <perl@shiar.org>
Wed, 27 May 2020 17:48:12 +0000 (19:48 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Sat, 6 Jun 2020 01:49:20 +0000 (03:49 +0200)
writer.plp

index 5b81a20e5f6d6df90c2e2ddb2e1a071c480e9465..92459150c238528a31156858f5805cba6902eeb3 100644 (file)
@@ -210,11 +210,16 @@ elsif ($ENV{REQUEST_METHOD} eq 'POST') {{
                                '-strip', -quality => '60%', -interlace => 'plane',
                                $imgpath => $thumbpath
                        );
-                       my $status = system @cmds;
-                       $status == 0 or Alert([
+                       eval {
+                               require IPC::Run;
+                               my $output;
+                               IPC::Run::run(\@cmds, '<' => \undef, '>&' => \$output)
+                                       or die $output ||
+                                               ($? & 127 ? "signal $?" : "error code ".($? >> 8))."\n";
+                       } or Alert([
                                "Thumbnail image not generated",
-                               "Failed to convert source image, error code ".($status >> 8),
-                       ], "@cmds");
+                               "Failed to convert source image.",
+                       ], "@cmds\n$@");
                }
                else {
                        unlink $thumbpath;